i want create array of strings, first use:
char** p = malloc(sizeof(char*) * count); // count number of strings
but trouble comes when want initialize strings:
for (int = 0; < count; i++) { char* s = malloc(size_of_each_string); *p + = s; // step induces error while (*s++ = *input++); // initialize copy }
so i'm confused. *p+i seems pointer arithmetic shifts pointer. pointer assignment in general allowed (point same object). why such assignment not allowed? , how around accomplish task?
the error message is: expression not assignable.
use *(p+i)=s
instead of *p+i=s
.
the things you're trying keep s in (p+i)
address. need use *(p+i)
instead of *p+i
.
about error message:
here arithmetic expression *p+i derive value. can save value memory address. you're getting error message.
Comments
Post a Comment