How to improve this C++ code to accept spaces in i
#include <iostream.h>
#include <conio.h>
main()
{
char res;
int index=0;
char names[index][20];//names each 20 characters long
do
{
cout<<"\nEnter name "<<(index + 1)<<": ";
cin>>names[index];
cout<<"\nWant to continue?";
cin>>res;
if (res == 'y' || res == 'Y')
index++;
}while(res == 'y' || res == 'Y');
cout<<"\nprogram terminated!";
getch();
}
Why this program does not accept spaces?
MAXOOD!
Life is an endless journey towards perfection
__________________
MAXOOD!
Life is an endless journey towards perfection
|