Cin issues?

So whatever reason whenever I ask the user for the job name the loop skips over the cin statement.

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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <iostream>

using namespace std;

int main()
{
int num_employees;
char employee;
int hours_worked[6];
int cost_code[6];	//cost code is what the employee did at a specific job
char job_name[6];
int job_code[6];	//each job has a specific code
	
const char* day_of_week[6];
day_of_week[0] = "Monday";
day_of_week[1] = "Tuesday";
day_of_week[2] = "Wednesday";
day_of_week[3] = "Thursday";
day_of_week[4] = "Friday";
day_of_week[5] = "Saturday";
day_of_week[6] = "Sunday";

int days = 6;

cout << "How many employees worked this week?" << endl;
cin >> num_employees;

for (int i = 0; i < num_employees; i++)
	{
		cout << "Enter employee number " << i+1 << "'s name: " << endl;
		cin >> employee;
		
			for(int j = 0; j < days; j++)
				{
					cout << "What job did " << employee << " work at on " << day_of_week[j] << "?" << endl;
					cin >> job_name[j];
				}
				
			for(int k = 0; k < days; k++)
				{
					cout << "What is the job code for " << job_name[k] << "?" << endl;
					cin >> job_code[k];
				}
				
			for(int l = 0; l < days; l++)
				{
					cout << "What is the cost code for " << job_name[l] << "?" << endl;
					cin >> cost_code[l];
				}
				
			for(int m = 0; m < days; m++)
				{
					cout << "How many hours did " << employee << " work on " << day_of_week[m] << " at " << job_name[m] << "?" << endl;
					cin >> hours_worked[m];
				}
	}			

return 0;
}
Are employee name and job name a single character?
Because if you enter "John" as employee name it will:
1) Store 'J' as employee name
2) Store 'o' as first job name
3) store 'h' as second job name
4) Store 'n' as third job name
5) Ask you for the name of fourth job.

Use std::string found in <string> header to store strings (names)
At the end of line 35 try using a newline character: '\n'

using << endl; can clear the buffer in the stream and this may be causing your issue, not positive, but worth a shot.
using << endl; can clear the buffer
It should flush the buffer. That what is endl for.
this may be causing your issue
It cannot. First of all input and output buffers are two distinct buffers. Second: output buffer is always flushed before any input operation. Third: buffered operations should not have any difference in behavior from unbuffered: buffering should be transparent.
good answer MiiNiPaa, I didn't know that!
Topic archived. No new replies allowed.