I am wondering what would be the equivalent of the following initialization.
char array[3][32] = { "string0", "string1" , "string2"};
The above code works but it has the risk of variable being initialized more than once.
I tried this but it only got the last number instead of the whole string.
char array[3][32];
*array[0] = 'string0';
*array[1] = 'string1';
*array[2] = 'string2';
Thank you in advance for the help!
>Solution :
You should use strcpy() to copy C-style strings.
Also '' is for character constants. You should "" for string literals.
char array[3][32];
strcpy(array[0], "string0");
strcpy(array[1], "string1");
strcpy(array[2], "string2");