+ 1
strcpy problem
what is my mistake? I want to copy "Copy" to my strings list but it doesn't work! https://code.sololearn.com/cA4a5A18a2A2/#c
11 odpowiedzi
+ 1
you are mixing arrays with pointers. and in C this is not a list but an array.
correct way could be:
#include <stdio.h>
#include <string.h>
int main()
{
char message[10][10] = { "Hello!" ,"Good Bye!","1202","15","14","16"};
printf("%s\n",message[0]);
strcpy(message[0], "Copy");
printf("%s\n", message[0]);
return 0;
}
0
thank you a lot Flash