Click here to Skip to main content
15,901,284 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How to develop an XML file using VC++ Pin
Cedric Moonen22-May-07 20:19
Cedric Moonen22-May-07 20:19 
GeneralRe: How to develop an XML file using VC++ Pin
kunal.tawde22-May-07 22:40
kunal.tawde22-May-07 22:40 
AnswerRe: How to develop an XML file using VC++ Pin
Hamid_RT22-May-07 21:05
Hamid_RT22-May-07 21:05 
GeneralRe: How to develop an XML file using VC++ Pin
kunal.tawde22-May-07 22:43
kunal.tawde22-May-07 22:43 
GeneralRe: How to develop an XML file using VC++ Pin
Hamid_RT22-May-07 23:39
Hamid_RT22-May-07 23:39 
QuestionPassing a pointer to a function/dynamic memory allocation Pin
hpjchobbes22-May-07 19:44
hpjchobbes22-May-07 19:44 
AnswerRe: Passing a pointer to a function/dynamic memory allocation Pin
Cedric Moonen22-May-07 19:58
Cedric Moonen22-May-07 19:58 
AnswerRe: Passing a pointer to a function/dynamic memory allocation Pin
cmk22-May-07 20:02
cmk22-May-07 20:02 
In short:
int  GetFooList( FooStruct **ppFoos ) {
   ...
   *ppFoos = new FooStruct[MaxFoos];
    return(MaxFoos);
}
FooStruct  *pFoos = NULL;
int         nFoos = GetFooList(&pFoos);


In long:
A pointer is just another data type like an integer (char, short, int, long, long long) or real (float, double).

So, turn the function around, what if you wanted to return the pointer and update the size as a parameter:
FooStruct*  GetFooList( int *nFoos ) {
   ...
   FooStruct  *pfs = new FooStruct[MaxFoos];
   *nFoos = MaxFoos;
   return(pfs);
}
int         nFoos = 0;
FoosStuct  *pFoos = GetFooList(&nFoos);


Don't get wrapped up by the fact that a pointer data type is defined with a *.

[EDIT]
Or, as Cedric pointed out, use references.
I was trying to stay with a pointer based explaination.
[/EDIT]


...cmk

Save the whales - collect the whole set

AnswerRe: Passing a pointer to a function/dynamic memory allocation Pin
Arman S.22-May-07 20:04
Arman S.22-May-07 20:04 
AnswerRe: Passing a pointer to a function/dynamic memory allocation Pin
zhang80060522-May-07 20:34
zhang80060522-May-07 20:34 
AnswerRe: Passing a pointer to a function/dynamic memory allocation Pin
David Crow23-May-07 4:21
David Crow23-May-07 4:21 
AnswerRe: Passing a pointer to a function/dynamic memory allocation Pin
hpjchobbes23-May-07 5:03
hpjchobbes23-May-07 5:03 
Questionmenu change for child window Pin
prithaa22-May-07 19:40
prithaa22-May-07 19:40 
AnswerRe: menu change for child window Pin
Anurag Gandhi22-May-07 19:48
professionalAnurag Gandhi22-May-07 19:48 
GeneralRe: menu change for child window Pin
prithaa22-May-07 21:11
prithaa22-May-07 21:11 
Questionerror in a very simple VC++ program Pin
tyagineha22-May-07 19:09
tyagineha22-May-07 19:09 
AnswerRe: error in a very simple VC++ program Pin
Anurag Gandhi22-May-07 19:33
professionalAnurag Gandhi22-May-07 19:33 
GeneralRe: error in a very simple VC++ program Pin
tyagineha22-May-07 20:06
tyagineha22-May-07 20:06 
GeneralRe: error in a very simple VC++ program Pin
Hamid_RT23-May-07 6:17
Hamid_RT23-May-07 6:17 
AnswerRe: error in a very simple VC++ program Pin
Sarath C22-May-07 19:41
Sarath C22-May-07 19:41 
AnswerRe: error in a very simple VC++ program Pin
tyagineha22-May-07 23:32
tyagineha22-May-07 23:32 
GeneralRe: error in a very simple VC++ program Pin
Sarath C22-May-07 23:54
Sarath C22-May-07 23:54 
AnswerRe: error in a very simple VC++ program Pin
tyagineha23-May-07 0:24
tyagineha23-May-07 0:24 
GeneralRe: error in a very simple VC++ program Pin
Sarath C23-May-07 0:26
Sarath C23-May-07 0:26 
AnswerRe: error in a very simple VC++ program [modified] Pin
tyagineha23-May-07 0:37
tyagineha23-May-07 0:37 

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.