typedef struct {
char * array[10];
} List;
int main(void) {
List input;
input.array = (char **)malloc(10 * sizeof(char));
if (input.array == NULL)
exit(EXIT_FAILURE);
for (i = 0; i < 10; i++) {
input.array[i] = (char *)malloc(10 * sizeof(char));
if (input.array[i] == NULL)
exit(EXIT_FAILURE);
}
}
I am attempting to initialize an array of 10 char pointers that each point to a different string of length 10.
I am receiving the following error from gcc:
incompatible types when assigning to type ‘char *[10]’ from type ‘char **’
My call to malloc must not be correct, but how so?