Hi, I need some tips on how to fix the errors of this program. I do not understand what the linker errors are telling me. thanks in advanced.

the errors are

Error 1 error LNK2005: _main already defined in test.obj test2.obj
Error 2 fatal error LNK1169: one or more multiply defined symbols found

#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>

using namespace std;

int main(){
	ifstream inFile;
	ofstream outFile;

	double test1, test2, test3, test4, test5;
	double average;

	string firstName;
	string lastName;
	
	inFile.open("test2.txt");
	outFile.open ("testavg.out");
		
	outFile << fixed << showpoint;
	outFile << setprecision(2);
	
	cout << "Processing data" << endl;

	inFile >> firstName >> lastName;
	outFile << "Test scores: " << setw(6) << test1
		<< setw(6) << test2 << setw(6) << test3
		<< setw(6) << test4 << setw(6) << test5 << endl;

average = (test1+test2+test3+test4+test5) / 5.0;

outFile << "Average test score: " << setw(6)
	<< average << endl;

	inFile.close();
	outFile.close();

	return 0;
}

The project you are compiling contains at least two main() functions, one in test.cpp and the other in test2.cpp. You need to delete one of the two main() functions, or one of the two *.cpp files.

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.