cin.getline skips a line, how to fix?
Feb 20, 2011 at 9:57am
cin.getline skip a line when it reaches the age cin.I don't know how to fix it yet.I'd be thankful for any help!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
#include <iostream>
#include <string>
using namespace std;
struct info {
char fname[30];
char lname[30];
char mname[30];
int age;
char address[30];
}male,female;
int main()
{
cout<<"First Name: ";
cin.getline (male.fname,30);
cout<<"Last Name: ";
cin.getline (male.lname,30);
cout<<"Middle Name: ";
cin.getline (male.mname,30);
cout<<"Age: ";
cin>> csdp.age;
cout<<"Address: ";
cin.getline (male.address,30);
cout<<"Press Enter to Exit!"<<endl;
cin.ignore(1);
return 0;
}
|
Feb 20, 2011 at 10:18am
ok found an answer in one of the post's here so don't bother with this anymore!
Feb 20, 2011 at 10:18am
ok found an answer in one of the post's here so don't bother with this anymore!
Topic archived. No new replies allowed.