cin.getline with while loop prob?

Everything is fine but after the while loop the input was crapped.. why?

int main()
{

char cont;
char name[100], birth[100], address[100]; //to declared user name, birth and address
double netIncome, tax; //to declared the user net income and total tax

do{

cout << "Name: ";
cin.getline(name, 100);


cout << "Date of birth: ";
cin.getline(birth, 100);

cout << "Address: ";
cin.getline(address, 100);


cout << "\nDo you want to continue?(Y/N)";
cin >> cont;

system("cls"); // clear screen
}while(cont == 'Y' | cont == 'y');


system("pause");
return 0;
}



It became like this after I reEnter the loop
Name: Date of birth:
Last edited on
cin >> leaves a newline char in the stream which is found by getline. Add a cin.ignore() after cin >> to remove it.
Also, the tags are [code].
Topic archived. No new replies allowed.