The goal of my program is to load data from a file into the sales array and then display each cities sales for each day before moving onto the next city. I am having problems passing my two dimensional SalesArray to my other functions. I am pretty sure it is because of the way I am declaring it in global and in main. I am also having a problem organizing it so it displays each city and days accordingly.
Any help would be great. Thank you
#include <iostream>
#include <iomanip>
#include <string>
#include <fstream>
#include <time.h>
using namespace std;
double SalesArray;
void GetSales();
void DisplaySales(double SalesArray[5][4]);
int main(){
DisplayHeading();
GetSales();
DisplaySales(double(SalesArray)[5][4]) ;
cout << endl;
system("pause");
return 0;
}
void GetSales(){
double SalesArray[5][4];
ifstream indata;
indata.open("sales.txt");
for (int row = 0; row < 5; row++){
for (int col = 0; col < 4; col++){
indata >> SalesArray[row][col] ;
}
}
//Close the File
//indata.close();
//cout << endl;
}
void DisplaySales(double SalesArray[5][4]){
for (int row = 0; row < 5; row++){
for (int col = 0; col < 4; col++){
cout << fixed << setprecision(2) << SalesArray[row][col] << endl;
}
}
// Array for City
const int SIZE = 5;
string city[SIZE] = {"New York" , "LA" ,
"Chicago" , "Springfield" ,
"Prophetstown" };
for (int count = 0; count < SIZE; count ++){
cout << city[count] << endl;
}
// Array for Days
const int SALES = 4;
string days[SALES] = {"Friday" , "Saturday" ,
"Sunday" , "Monday"
};
for (int count = 0; count < SALES; count ++){
cout << days[count] << endl;
}
}