I originally had my arrays in my function so i was losing all the data from the arrays moving on to the next function leaving me stuck for days. after staying up all night, I realize I need to create my arrays in the Main so i don't lose them once I do work with them in the function but once I initiated them in the Main and passed them through the parameters, my program freaked out and keeps breaking! can someone tell me what I am doing wrong here? thank you
#include<iostream>
#include<string>
#include<fstream>
#include<cstdlib>
#include<iomanip>
#include<sstream>
using namespace std;
void getData(int arr[][8],string name[50], int length);
int main() {
int arr[50][8];
arr[0][7];
string name[50];
getData({},{},{});
system("pause");
}
void getData(int arr[][8],string name[50], int length) {
ifstream fin;
fin.open("empdata2.txt");
int i;
fin >> i;
if (fin.fail()) {
cout << " Your file was unable to open.\n\n";
exit(1);
}
string name;
int arr;
int total = 0;
for (int row = 0; row < i; ++row) {
fin >> name[row];
cout << name[row] << " ";
total = 0;
for (int day = 0; day < 7; day++) {
fin >> arr[row][day]; //where the break keeps happening
total += arr[row][day];
sorry. I just got on this site this last week. still getting the navigation down. I thought when i hit that that was resolved (even though it wasn't) that it was deleted. my mistake.