Get a paper and draw what you want.
Let me make an example, but without the typedef, which in my opinion is not helping.
You need to allocate space, equal to the length of the string, plus one for the null terminator of strings!
Code:
sizeof(strlen(s)+1)
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MESSAGE_SIZE 100
int main(void) {
/* Declare an array of char pointers.
MESSAGE_SIZE is the number of these pointers.
Every pointer is to point to a string.
*/
char* messages[MESSAGE_SIZE];
char *s = "hello world";
/* Make the first pointer of the array, to point
to 's'.
*/
/* First, you need to make room for the string,
plus the null terminator.
*/
messages[0] = malloc(sizeof(strlen(s)+1));
/* Now copy the content of 's' to the array (at position 0). */
strcpy(messages[0], s);
printf("%s\n", messages[0]);
return 0;
}
Or, if you are sure that 's' will be in scope as long as your program executes, you can simply make the pointer to point to s, like this