Possible Duplicate:
getline not asking for input?
There is some unique thing happening in my program. Here are some set of commands :
cout << "Enter the full name of student: "; // cin name
getline( cin , fullName );
cout << "\nAge: "; // cin age
int age;
cin >> age ;
cout << "\nFather's Name: "; // cin father name
getline( cin , fatherName );
cout << "\nPermanent Address: "; // cin permanent address
getline( cin , permanentAddress );
When i try to run this snippet along with the whole code.The output program works like :
output:
Enter the full name of student:
Age: 20
Father's Name:
Permanent Address: xyz
If you notice ,the program didn't ask me the full name and went on directly to ask me the age.Then it skips the father's name also and asks the permanent address. What could be the reason for this ?
It is difficult for me to post the whole code because it is too large.
int age
?getline
's, which only takes astd::string
as the target?cin
's? Really no justification for -1. – Cowling