I'm beginner in the studies of C language (not C++) and I'm trying to define a dynamic array of strings, but I'm experiencing difficulties for appending an element.
I have tried to define the array as:
char **e = malloc(3 * sizeof(char *));
e[0] = "abc";
e[1] = "def";
e[2] = "ghi";
It ran successfully, but trying to resize it, using:
**e = realloc(e, 4 * sizeof(char *));
Returned the error: "assignment makes integer from pointer without a cast". What am I doing wrong?
Thanks, Fábio
**in your assignment:e = realloc(e, 4 * sizeof(char *));malloc()andrealloc()before using them. Both functions can fail and, if they do, subsequent behaviour of code using the returned values will be undefined.