How to declare an array to store the different five(5) name and initialize the following char array with {"Lara","Lin","Nitin","Krishna","Sophia"}

You pretty much have it:

char array[]= {"Lara","Lin","Nitin","Krishna","Sophia"};

If you want the names on their own row, then add another dimension to the array:

char array[5][] = { {"Lara"}, {"Lin"}, etc.

i use the same but its not work it gave an error " error C2078: too many initializers "
char array[]= {"Lara","Lin","Nitin","Krishna","Sophia"};

char *array[]= {"Lara","Lin","Nitin","Krishna","Sophia"};

Add the asterisk! ;)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.