Beginner c++ need help with arrays

Hello everyone. I'm new here and I have a code that I need help with. I'm currently enrolled in a intro C++ course in college and I am feeling very lost. As of now I am using Visual Studio 2013 and I am working on arrays. I have compiled a code from the book. For this assignment, I am supposed to use an I/O manipulator,setw(15), setprecision(2) setiosflags(ios::fixed|ios::showpoint|ios::left) but I don't know where this would go.

My code runs, but the output screen quickly disappears before I can read the output.

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<iomanip>
using namespace std;
int main(){
	char empid[100][12];
	char firstname[100][10], lastname[100][15];
	int hw[100];
	double gp[100], np[100], hr[100], taxrate[100], taxamt[100];
	int counter = 0;
	int i;
	cout << "ENTER EMP ID, FIRSTNAME, LASTNAME, HRS WORKED, HRLY RATE ctrl z to end" << endl;
	while (cin >> empid[counter] >> firstname[counter] >> lastname[counter] >> hw[counter] >> hr[counter])
		counter = counter + 1;
	for (i = 0; i < counter; i++){
		gp[i] = hw[i];}//end gross pay for loop
	for (i = 0; i < counter; i++){
		if (gp[i]>500)taxrate[i] = .30;
		else if (gp[i]>200)taxrate[i] = .20;
		else taxrate[i] = .10;
	}//FOR
	for (i = 0; i < counter; i++){
		taxamt[i] = gp[i] * taxrate[i];}//end taxamount for loop
	for (i = 0; i < counter; i++){
		np[i] = gp[i] - taxamt[i];}//end netpay for loop
	cout << endl;
	cout << setw(14) << "EMPLOYEE ID" << setw(16) << "FIRST NAME" << setw(17) << "LASTNAME" << setw(4) << "HW" << setw(5) << "HR" << setw(6) << "GROSS" << setw(6) << "TAX" << setw(9) << "NET PAY" << endl << endl;
	for (i = 0; i < counter; i++){
		cout << setw(14) << empid[i] << setw(16) << firstname[i] << setw(17) << lastname[i] << setw(4) << hw[i] << setw(5) << hr[i] << setw(6) << taxamt[i] << setw(9) << np[i] << endl;
	}//FOR
	return 0;
}//MAIN 
At the end of your code, in between lines 29 and 30, simply add cin.sync(); cin.get();. What this will do is it will effectively ask for another character from your program, pausing it. To end your program, just press the "ENTER" (or sometimes "RETURN") button on your keyboard.
Thank you! That worked! But, for some reason, I am able to get an output and type employee name ID, name, etc.

But, it will close when I get to entering it in a tabular format. I guess the code is wrong?
Topic archived. No new replies allowed.