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);

I am smacking myself in the face for that one thanks guys.

Is nobody else going to point out that he's trying to return a value with a void function?

How you know that?

The function is empty at the moment..

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

}

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.