0
J'ai des problèmes avec les pointeurs struct ... Voici deux exemples dans mon code qui font essentiellement la même chose sauf que dsp n'est pas un pointeur et InMemory [Idx ] est un pointeur, comment utiliser memcpy dans le cas du pointeur?memcpy-ing à un feild d'un pointeur struct dans c
my_struct* InMemory[SIZE]
//works prints: tmp3:local_file (file name)
memcpy(dsp.result.list[i].owner_name,req.file_name,256);
char tmp3[256];
memcpy(tmp3,dsp.result.list[i].owner_name,256);
printf("tmp3:%s\n",tmp3);
//doesn't work, prints: tmp:_____<---nothing! ??
//I am trying to copy the result from above into a field of the struct pointer array
char tmp2[256];
memcpy(InMemory[Idx]->filename,dsp.result.list[i].owner_name,256);
memcpy(tmp2,InMemory[Idx]->filename,256);
printf("tmp:%s\n",tmp2);
Êtes-vous allouer les éléments de InMemory quelque part? – imreal
oui j'utilise malloc pour lui donner de la mémoire – spatara
@spatara, pouvez-vous s'il vous plaît ajouter ce code aussi? – Anon