tables?

How do I display the entered data in table form?
And is the code even right?

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
//Include Files
#include <iostream>
#include <iomanip>
#include <conio.h>
#include <fstream>
using namespace std;

fstream file;

struct comDiv
{
	string divName;
	float sales[4];
	float totalDivSales;
};

int j;
struct division;

file.open("corpdata.txt", ios::in | ios::binary);

//Function Prototypes

//Main
int main()
{

	for (int index = 0; index < 4; index++)  //for i 4 times
		{
			cout << "Enter Division name for division #1: ";
			cin >> division[index].divName; //input region name: division[i].divName
		for (index = 0; j < 4; j++) //nested for j 4 times
			{
				cout "Enter sales for " << division[index].divName; ": ";
				cin >> division[index].sales[j]; //input sales for region: division[i].sales[j]
			}
		}	
	cout << "------------------------------------------------------" << endl;

		
	getch();
	return 0;
}
My guess is that struct division; should be comDiv division[4];

Division Sales Div Total Div Average

East Qtr 1 Qtr 2 Qtr 3 Qtr 4
West # # # # # #
North # # # # # #
South # # # # # #

The data is supposed to be displayed like above ^
How do I do that?
use std::cout. Take a shot at it. You may have to fiddle with iomanipulators to format the output for each line correctly.
http://cplusplus.com/doc/tutorial/basic_io/
http://cplusplus.com/reference/iostream/manipulators/
Last edited on
Topic archived. No new replies allowed.