View Single Post
  #1 (permalink)  
Old July 22nd, 2008, 01:10 PM
code_lover code_lover is offline
Authorized User
 
Join Date: Jan 2007
Posts: 46
Thanks: 2
Thanked 1 Time in 1 Post
Default 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
Reply With Quote