I've tried to create a function that duplicate a structure into a pointer, but here is the issue, there is a char
tab into the structure and I can't assign my original value to the new structure.
The function :
Planete *dupliquer(Planete *p){
Planete *res;
res = (Planete*) malloc(sizeof(Planete));
if(res == NULL){
printf("Erreur d'allocation...\n");
exit(1);
}
res->nomplanete = p->nomplanete;
res->rayon = p->rayon;
return res;
}
And here is the compilator error :
error: incompatible types when assigning to type ‘char[20]’ from type ‘char *’
res->nomplanete = p->nomplanete;
^
Can you please help me, It will be very nice. Thanks for your support !