P
Poof
This is part of a database-kind-of program.
char name[50];
int age;
for(int x = 0; x < 2; x++)
{
cout << "Enter your name : ";
cin.getline(name, 50);
cout << "Enter your age : ";
cin >> age;
}
It runs fine the first time round the loop, but during its second run, it'll
skip the cin.getline part and go straight to "Enter your age : ";
So the output for the second run becomes
"Enter your name : Enter your age : "
It works fine if I use cin >> instead of cin.getline().... Anyone has any
idea?
Any responses are greatly appreciated!
char name[50];
int age;
for(int x = 0; x < 2; x++)
{
cout << "Enter your name : ";
cin.getline(name, 50);
cout << "Enter your age : ";
cin >> age;
}
It runs fine the first time round the loop, but during its second run, it'll
skip the cin.getline part and go straight to "Enter your age : ";
So the output for the second run becomes
"Enter your name : Enter your age : "
It works fine if I use cin >> instead of cin.getline().... Anyone has any
idea?
Any responses are greatly appreciated!