Click here to Skip to main content
16,014,765 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questiondatatransfer Pin
Mohanraj D18-May-08 22:59
Mohanraj D18-May-08 22:59 
AnswerRe: datatransfer Pin
CPallini18-May-08 23:07
mveCPallini18-May-08 23:07 
GeneralRe: datatransfer Pin
Mohanraj D18-May-08 23:19
Mohanraj D18-May-08 23:19 
GeneralRe: datatransfer Pin
CPallini18-May-08 23:26
mveCPallini18-May-08 23:26 
GeneralRe: datatransfer Pin
Mohanraj D18-May-08 23:31
Mohanraj D18-May-08 23:31 
GeneralRe: datatransfer Pin
CPallini18-May-08 23:37
mveCPallini18-May-08 23:37 
GeneralRe: datatransfer Pin
Mohanraj D18-May-08 23:53
Mohanraj D18-May-08 23:53 
GeneralRe: datatransfer Pin
CPallini19-May-08 0:08
mveCPallini19-May-08 0:08 
I strogly suggest you following the toxcct's article approach.

Anyway, using the global variable approach is simple:
(1) declare, in a common included header file, the variable as extern.
(2) define the variable only in one source file.

For instance, in your main header file (let's assume it is YourApp.h)
extern CString g_MyString; // declaration as extern


and in the main source file, and only there (let's assume again it is YourApp.cpp)
CString g_MyString; // definition


Now you can use g_MyString in any *.cpp file that includes the main header file (i.e. YourApp.h).


You may find a working example of global variable in your sources, since Visual Studio generates code for the global variable theApp.
Smile | :)

If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.

This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke


GeneralRe: datatransfer Pin
Nelek19-May-08 7:37
protectorNelek19-May-08 7:37 
GeneralRe: datatransfer Pin
Mohanraj D19-May-08 20:18
Mohanraj D19-May-08 20:18 
GeneralRe: datatransfer Pin
Mohanraj D19-May-08 20:19
Mohanraj D19-May-08 20:19 
AnswerRe: datatransfer Pin
Rajesh R Subramanian19-May-08 1:04
professionalRajesh R Subramanian19-May-08 1:04 
GeneralRe: datatransfer Pin
David Crow19-May-08 4:00
David Crow19-May-08 4:00 
AnswerRe: datatransfer Pin
Hamid_RT19-May-08 1:34
Hamid_RT19-May-08 1:34 
Questionproblem with fwrite Pin
Cadimi18-May-08 22:50
Cadimi18-May-08 22:50 
QuestionRe: problem with fwrite Pin
CPallini18-May-08 22:56
mveCPallini18-May-08 22:56 
AnswerRe: problem with fwrite Pin
Cadimi19-May-08 2:28
Cadimi19-May-08 2:28 
QuestionRe: problem with fwrite Pin
CPallini19-May-08 2:56
mveCPallini19-May-08 2:56 
AnswerRe: problem with fwrite Pin
Cadimi19-May-08 3:10
Cadimi19-May-08 3:10 
QuestionRe: problem with fwrite Pin
CPallini19-May-08 3:15
mveCPallini19-May-08 3:15 
AnswerRe: problem with fwrite Pin
Cadimi19-May-08 3:20
Cadimi19-May-08 3:20 
QuestionRe: problem with fwrite Pin
CPallini19-May-08 3:25
mveCPallini19-May-08 3:25 
AnswerRe: problem with fwrite Pin
Cadimi19-May-08 3:33
Cadimi19-May-08 3:33 
QuestionRe: problem with fwrite Pin
CPallini19-May-08 3:45
mveCPallini19-May-08 3:45 
AnswerRe: problem with fwrite Pin
Cadimi19-May-08 4:00
Cadimi19-May-08 4:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.