Click here to Skip to main content
16,004,927 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: passing array of pointers Pin
Christian Graus15-Nov-06 17:21
protectorChristian Graus15-Nov-06 17:21 
GeneralRe: passing array of pointers Pin
thathvamsi15-Nov-06 17:23
thathvamsi15-Nov-06 17:23 
GeneralRe: passing array of pointers Pin
Christian Graus15-Nov-06 17:30
protectorChristian Graus15-Nov-06 17:30 
GeneralRe: passing array of pointers Pin
thathvamsi15-Nov-06 18:55
thathvamsi15-Nov-06 18:55 
GeneralRe: passing array of pointers Pin
Christian Graus15-Nov-06 19:12
protectorChristian Graus15-Nov-06 19:12 
GeneralRe: passing array of pointers Pin
thathvamsi15-Nov-06 20:06
thathvamsi15-Nov-06 20:06 
GeneralRe: passing array of pointers Pin
Christian Graus15-Nov-06 20:10
protectorChristian Graus15-Nov-06 20:10 
GeneralRe: passing array of pointers Pin
thathvamsi15-Nov-06 21:45
thathvamsi15-Nov-06 21:45 
Thanks very much for your help. It has been a good learning experience.
Back to my sqaure1 problem,,,,In the following code, the names are null when i try to access them inside funcB. why?
Should I do malloc for Names? if so, how?

funcA{<br />
array = 4;<br />
char * Names[array];<br />
int next = 0;<br />
int i;<br />
<br />
//initialise <br />
for(i=0;i<array+1;i++)<br />
{<br />
Names[i]=NULL;<br />
}<br />
<br />
char * list = "Abc";<br />
Names[ next ] = malloc( sizeof( char )*( strlen( list ) + 1 ) );<br />
memcpy( Names[ next ],list,sizeof( char )*( strlen( list ) + 1 ) );<br />
<br />
list = "cdefg";<br />
Names[ next+1 ] = malloc( sizeof( char )*( strlen( list ) + 1 ) );<br />
memcpy( Names[ next+1 ],list,sizeof( char )*( strlen( list ) + 1 ) );<br />
<br />
printf("vsp list got is %s\n", Names[0] );<br />
printf("vsp list got is %s\n", Names[1] );<br />
<br />
funcB(....,...,(const char**)&Names);<br />
}<br />
<br />
funcB(...,...,const char ** names)<br />
{<br />
....<br />
//the actual values names[0] and names[1] are to be accessed and used but they are null!!!???<br />
...<br />
//free names[0] and names[1]<br />
free( (char*)names[0]);<br />
free( (char*)names[1]);<br />
<br />
}

GeneralRe: passing array of pointers Pin
Christian Graus15-Nov-06 21:56
protectorChristian Graus15-Nov-06 21:56 
GeneralRe: passing array of pointers Pin
thathvamsi15-Nov-06 22:12
thathvamsi15-Nov-06 22:12 
GeneralRe: passing array of pointers Pin
Christian Graus15-Nov-06 22:30
protectorChristian Graus15-Nov-06 22:30 
GeneralRe: passing array of pointers Pin
Christian Graus15-Nov-06 22:35
protectorChristian Graus15-Nov-06 22:35 
GeneralRe: passing array of pointers Pin
thathvamsi15-Nov-06 23:08
thathvamsi15-Nov-06 23:08 
GeneralRe: passing array of pointers Pin
Christian Graus15-Nov-06 23:11
protectorChristian Graus15-Nov-06 23:11 
GeneralRe: passing array of pointers Pin
Christian Graus15-Nov-06 23:09
protectorChristian Graus15-Nov-06 23:09 
GeneralRe: passing array of pointers Pin
thathvamsi15-Nov-06 23:19
thathvamsi15-Nov-06 23:19 
GeneralRe: passing array of pointers Pin
Christian Graus15-Nov-06 23:22
protectorChristian Graus15-Nov-06 23:22 
GeneralRe: passing array of pointers Pin
Christian Graus15-Nov-06 23:23
protectorChristian Graus15-Nov-06 23:23 
GeneralRe: passing array of pointers Pin
thathvamsi15-Nov-06 23:33
thathvamsi15-Nov-06 23:33 
AnswerRe: passing array of pointers Pin
Raj Prathap15-Nov-06 18:47
Raj Prathap15-Nov-06 18:47 
GeneralRe: passing array of pointers Pin
thathvamsi15-Nov-06 18:53
thathvamsi15-Nov-06 18:53 
GeneralRe: passing array of pointers Pin
Raj Prathap15-Nov-06 20:47
Raj Prathap15-Nov-06 20:47 
QuestionFrustrated with conversion Pin
Stick^15-Nov-06 15:14
Stick^15-Nov-06 15:14 
AnswerRe: Frustrated with conversion Pin
Christian Graus15-Nov-06 15:24
protectorChristian Graus15-Nov-06 15:24 
GeneralRe: Frustrated with conversion Pin
Stick^15-Nov-06 16:02
Stick^15-Nov-06 16:02 

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.