strange output

According to my code I was expecting to have the option of entering the variable sex..but in somehow It's skipping it...I dont know why...there will be something in the code that I cant imagine...

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
  
const worker& Copy(worker& a){
		cout<<"Enter name";
		cout<<" ";
		getline(cin,a.name);
		cout<<"\n";
		
		cout<<"Enter age";
		cout<<" ";
		cin>>a.age;
		cout<<"\n";
		
		cout<<"Enter sex";
		cout<<" ";
		getline(cin,a.sex);
		cout<<"\n";
		
		cout<<"Enter job";
		cout<<" ";
		getline(cin,a.job);
		cout<<"\n";
		
		cin.ignore();
		return a;
		
	}



Output:

Enter name Javier

Enter age 54

Enter sex
Enter job Engineer
just add cin.ignore(); after getting age.
@rafae11, you should always add supplementary explanation to your answer. This helps the OP and others to understand the solution and learn.
Topic archived. No new replies allowed.