Hey there,
I'm working on a program that grades multiple-choice exams. It compiles, but I keep getting a linking error, LNK2019: unresolved external symbol. I can't find this unresolved symbol, and I was wondering if someone else could. Or give some tips on how to fix it? And also, it's due in two hours, so quick help is appreciated!
Code:
Code:#include <iostream> #include <string> #include <fstream> using namespace std; void OpenFiles (ifstream& inFile, ofstream& outFile); void WrongSize (ofstream& outFile, int keylength, string answers, string key); int main() { ifstream inFile; ofstream outFile; OpenFiles(inFile, outFile); if (!inFile || !outFile) { cout << "Error opening files." << endl; return 1; } string key; string student; string answers; int keylength; inFile >> key; keylength = key.length(); while(inFile >> student >> answers) { outFile << student << " "; WrongSize(outFile, keylength, answers, key); } return 0; } //************************************************************** void OpenFiles(ifstream& inFile, ofstream& outFile) { string inFileName; string outFileName; cout << "Enter the name of the input file." << endl; cin >> inFileName; inFile.open(inFileName.c_str()); cout << "Enter the name of the output file." << endl; cin >> outFileName; outFile.open(outFileName.c_str()); outFile << "Scores for multiple-choice exam from " << inFileName << endl; outFile << fixed; } void WrongSize(ofstream& outFile, int keylength, string answers, string key) { int grade = 0; bool check; if (answers.length() < keylength) { outFile << "Too few answers"; } else if (answers.length() > keylength ) { outFile << "Too many answers"; } else { check = false; } for (int count = 0; count < key.length(); count++) { if( answers[count] == key[count] ) { grade++; } else if (answers[count] != 'a' && answers[count] != 'b' && answers[count] != 'c' && answers[count] != 'd' && answers[count] != 'e' && answers[count] != 'f') { check = true; } if (check == true) { outFile << "Invalid Answer"; } else { outFile << grade; } } outFile << endl; }



LinkBack URL
About LinkBacks


