The problem is that "names" are strings: each one is an array of
char
char name1[] = "Jack";
printf("%s\n", name1);
char name2[] = "Tom";
printf("%s\n", name2);
So you can't easily keep them in a one dimensional array like yours.
What you need is a one dimensional array of
pointer to char
values, each of which is a separate name:
char* names[] = {"Jack", "Tom", "John"};
for (int i = 0; i < 3; i++)
{
printf("%s\n", names[i]);
}
To read them in from the user is more complicated: you need to use
malloc
to allocate space for the data the user is going to type before each call to scanf, and store the pointer it returns in your
names
array.