-
Cin.getline skip data
Record is
char FirstName[25];
char Address[40];
int Age;
cout<<"enter first: ";
cin>>Firstname;
cout<<"enter address: "<<endl;
cin.getline(address, 60);
cout<<"enter age: ";
cin>>age;
output:
enter first: MyName
enter address:
enter age: 11
Problem: After entering firstname, I don't get a chance to enter address when it already skip to getting my age.
What could be the problem? How do I solve this? Thanks.
-
scroll up to top of page.....
look right....
click button that says search...
be safe in the knowledge that this question gets answered just about every day!
-
cin.ignore(80, '\n'); should soak up enough stray junk.