This program uses a structure to store the following data on a company division:
Division Name(such as East, West, North, or South)
Quarter(1, 2, 3, or 4)
Quarterly Sales
The user should be asked for the four quarters' sales figures for the East, West, North, and South divisions, and the data should be stored in the structure. This is my code so far, I'm not understand the concept properly:
#include "stdafx.h"
#include <iostream>
#include <fstream>
using namespace std;
struct Data{
char *name;
int quarter[4];
int sales;
};
int _tmain(int argc, _TCHAR* argv[])
{
Data division[4];
int count;
division[0].name = "East";
division[1].name = "West";
division[2].name = "North";
division[3].name = "South";
for(count = 0; count < 4; count++){
cout << "Please enter the sales for the " << division[count].name << " for: " << endl;
cout << "Quarter: " << count + 1 << ": " << endl;
cin >> division[count].quarter[count].sales;
}
cin.get();
return 0;
}
It seems my for
loop is not working at all, something is wrong with my cin
statement, because `division is showing a red underline.