I get this error: variable or field 'calc_score' declared void
and I am pretty much stuck. Here is my code, it obviously isn't finished but I need to be able to get this void to compile to continue on.

#include <fstream>
#include <iostream>
#include <cstdlib>
#include <iomanip>
using namespace std;

void calc_score(ifstream& fin, ofstream& fout);

int main()
{
char in_file_name[21], out_file_name[21];
ifstream fin;
ofstream fout;

cout<< "This program calculates the average of a list of grades.\n"
	 << "Enter the input file name (maximum of 20 characters):\n";
cin>> in_file_name; 
cout<< "Enter the output file name (maximum of 20 chracters):\n";
cin>> out_file_name;
cout<< "The numbers for the grades will be read from the file "
	 << in_file_name << "and\n"
	 << "placed into the file "
	 << out_file_name << "with the average of each grade set.\n";
	 
fin.open(in_file_name);
if(fin.fail( ))
{
cout<< "Input file opening failed!\n";
exit(1);
}

fout.open(out_file_name);
if(fout.fail( ))
{
cout<< "Output file opening failed!\n";
exit(1);
}

void calc_score(fin, fout);

fin.close( );
fout.close( );

return 0;
}

void calc_score(ifstream& fin, ofstream& fout)
{

}

Line 39 remove void. Only have to specify the function type when you declare it, not when you call it.

I think you should use:

calc_score(fin, fout);

instead of

void calc_score(fin, fout);

How you know that?

The function is empty at the moment..

void calc_score(ifstream& fin, ofstream& fout)
{

}

Edited 6 Years Ago by Chris911: n/a

Oh, whoops. I read this:

void calc_score(fin, fout);

fin.close( );

fout.close( );

return 0;
}

...and didn't realize it was the main function.

This question has already been answered. Start a new discussion instead.