#include <iostream>
#include <fstream>
#include <string>
using namespace std;
const int numRows=5;
const int numCol=7;
void openfile(ifstream& , ofstream& );
void initialize(ifstream& , ofstream& );
void ave(ifstream& ,ofstream& , double , double,string );
void printout(ifstream& , ofstream& ,string ,double ,double );
int main(){
ifstream infile;
ofstream outfile;
string names[numRows];
double results[numRows][numCol];
double average[numRows];
openfile(infile,outfile);
initialize(infile,outfile);
//ave(infile,outfile,results,average,names);
//printout(infile,outfile,names ,results,average);
return 0;
}
//this function is used to open up files and call on initilize
void openfile(ifstream& infile, ofstream& outfile){
infile.open("runnerslog.txt");
outfile.open("results.txt");
initialize(infile,outfile);
}
//this function initilizes my arrays and the calls on the average and print statements
void initialize(ifstream& infile, ofstream& outfile){
int i;
int j;
char names[numRows];
double results[numRows][numCol];
double average[numRows];
for(i=0; i<numRows; i++){
infile>>names[i];
}
for(i=0;i<numRows;i++){
for(j=0;j<numCol;i++)
infile>>results[i][j];
cout<<endl;
}
for(i=0;i<numRows;i++)
{
infile>>average[i];
}
}
void ave(ifstream& infile,ofstream& outfile, double results[numRows][numCol], double average[numRows],string names[numRows]){
int i;
int j;
int sum=0;
for(i=0; i<numRows;i++)
{
sum=0;
for(j=0;j<numCol;j++)
average[i]=average[i]+(results[i][j]/7);
printout(infile,outfile, names ,results,average);
}
}
void printout(ifstream& infile, ofstream& outfile ,string names[numRows],double results[numRows][numCol],double average[numRows]){
int i;
int j;
for(i=0; i<numRows; i++){
outfile<<names[i];
}
for(i=0;i<numRows;i++){
for(j=0;j<numCol;i++)
outfile<<results[i][j];
cout<<endl;
}
for(i=0;i<numRows;i++)
outfile<<average[i];
infile.close();
outfile.close();
}
I have coding in C++ that is suppose to read from a file that has five runners and their amount of miles they ran for seven days. I am suppose to then find the average and total miles they have ran. The error message I am getting is in line 70 for trying to output to the output file. It says error C2664: 'printout' : cannot convert parameter 3 from 'std::string []' to 'std::string' line 70