Am new to c++, and am having some problems in initilizing arrays that hold strings during the program.
I want to write a program that requests 5 names from the user
and then stores it in an array of character pointers.
Example:
int main()
{
clrscr();
char *names[5];
int ctr;
for(ctr=0; ctr<5; ctr++)
{
cout<<"\nWhat is the next name " ;
cin>>*(names+ctr);
}
for(ctr=0; ctr<5; ctr++)
{
cout<<"Names:\n\n ";
cout<<*(names+ctr) <<"\n";
}
return 0;
}
When a try to run this it just shows garbage . Can anyone give me a hint of where i went wrong.
Thanks in advance.