I'm trying to copy a string into an array of strings, but it doesn't work. I know it is a problem due to memory allocation but I don't see how I could make it work as STRING_LENGTH is a constant.
#define NUMBER_OF_STRINGS 3
#define STRING_LENGTH 255
char message_ecran[NUMBER_OF_STRINGS][STRING_LENGTH];
int i;
char texte3[] = "CVC";
char texte7[] = "iiiiiiiii";
for (i=0;i<=NUMBER_OF_STRINGS;i++)
{
strcpy(message_ecran[i], texte7);
}
strcpy(message_ecran[0], texte3);
Values of message_ecran after the code:
"CVC"
null
"iiiiiiiii"
expected values
"CVC"
"iiiiiiiii"
"iiiiiiiii"
message_ecran?