so basically i have four files named, "ASN, EXER,MID,FINAL" that have grades inputed in with the amount shown below.....all i want is to have them saved in an array so i can use them to calculate a grade....the code below is what i have right now, dont understand the errors, some help??
#include <fstream>
#include <iostream>
using namespace std;
int loadScores(double data[], int size, string fileName);
const int MAX_ASN = 11;
const int MAX_EXER = 12;
const int MAX_MID = 2;
const int MAX_FINAL = 2;
const string AREAS[] = {"Assignments", "Exercises", "Midterm", "Final Exam"};
const int INDEX_ASN = 0;
const int INDEX_EXER = 1;
const int INDEX_MID = 2;
const int INDEX_FINAL = 3;
int main() {
loadScores(double data[], int size, string fileName);
}
int loadScores(double data[], int size, string fileName) {
ifstream fin;
ofstream fout;
int data[MAX_ASN];
fin.open("asn.txt");
if (fin.fail()) {
cout << "Input file failed to open.\n";
exit(1);
}
int count = 0;
while(fin >> data[INDEX_ASN] && data[INDEX_ASN] < MAX_ASN) {
}
fin.open("exer.txt");
if (fin.fail()) {
cout << "Input file failed to open.\n";
exit(1);
}
int count = 0;
while(fin >> data[INDEX_EXER] && data[INDEX_EXER] < MAX_EXER) {
}
fin.open("mid.txt");
if (fin.fail()) {
cout << "Input file failed to open.\n";
exit(1);
}
int count = 0;
while(fin >> data[INDEX_MID] && data[INDEX_MID] < MAX_MID) {
}
fin.open("fin.txt");
if (fin.fail()) {
cout << "Input file failed to open.\n";
exit(1);
}
int count = 0;
while(fin >> data[INDEX_FINAL] && data[INDEX_FINAL] < MAX_FINAL) {
}
// Read the number of scores
// Also load scores into the data[]
int index = 0;
return index;
}
lastly....if your kind enough, can ya maybe post your aim or w/e wherein i can ask for your help a little quicker...dont really know if there are people out there that are that kind. but ya, thanks!