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"};

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

Add the asterisk! ;)

Thanks buddy for help.................

Be a part of the DaniWeb community

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