I am trying to figure out how to create an array of strings (considering I know the max length of each string).
char** strings = NULL;
strings = malloc (5*sizeof(char*));
Once I did that, how can I just fill the array without the need to allocate each string separately? Lets say I know the max length of a string is 20, how to I set it?
After the allocation of the string I wish to do the following:
strings[0] = "string";
strings[1] = "another string";
etc.
Thanks
char (*strings)[20+1] = malloc(5*sizeof(*strings)); strcpy(strings[0], "string");...char *strings[5] = { "string", "another string", };