The point of the program is to read from the file and then output to the other file, we HAVE to use an array as well as a function to do this.
The problem I am running into is well... several problems.
When I try to run the program I either get "cannot access private member declared in class which I fixed by placing an & next to ifstream, but that caused the error unexpected character... someone help please I am sure it is something simple but I seem to be missing it big time.
#include "stdafx.h"
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
using namespace std;
void Read_Data (ifstream, string, double, double, double, double, double);
int _tmain(int argc, _TCHAR* argv[])
{
string name[50]={};
double midterm[5]={};
double final[5]={};
double assignment1[5]={};
double assignment2[5]={};
double assignment3[5]={};
ifstream infile;
ofstream outfile;
infile.open ("grades.txt");
outfile.open ("report.txt");
if (!infile)
{
cout << "Error: Cannot open file grade.txt." << endl;
exit (1);
}
if (!outfile)
{
cout << "Error: Cannot open file report.txt." << endl;
exit (1);
}
outfile <<"Dr. David Smith, Associate Professor" << endl;
outfile << "Blue Ridge Community College" << endl;
outfile << "Name"<< setw(15) << "Midterm" << setw(9) << "Final" << setw(9) << "Asng1" <<setw(9) << "Asng2" <<setw(9) << "Asng3" << setw(9) << endl;
Read_Data (infile, name[50], midterm[5], final[5], assignment1[5], assignment2[5], assignment3[5]);
outfile << name << midterm << final << assignment1 << assignment2 << assignment3;
return 0;
}
void Read_Data(ifstream& infile, string name[50], double midterm[], double final[], double assignment1[], double assignment2[], double assignment3[])
{
int i;
for (i=0; i<10; i++);
infile >> name[i] >> midterm[i] >> final[i] >> assignment1[i] >> assignment2[i]>> assignment3[i];
return 0;
}