Hi, I am having trouble storing strings into an array. Basically I have a console program where it has an option.
This is just an example;
Code:
char name[max];
char listofnames[maxname];
int counter;
....
printf("Add names\n");
//Then a list of names
// they can select
switch(choice)
{
case 1:
strcpy(name,"kyle");
break;
case 2:
strcpy(name,"phil");
break;
etc...
}
//Now in there they have an option wether they like to add more names
// if they said "yes"
// the name chosen should be stored in array listofnames
// something like
if(strcmp(selection,"yes")==0)
{
listofnames[counter]=name;
// I AM HAVING TROUBLE STORING IT IN LISTOFNAMES ARRAY
}
if(strcmp(selection,"no")==0)
{
//printf list of names array
// AND HOW CAN I PRINT IT?
}
can anyone please help. thankyou