Thread: Help Needed Fast! Multiple Choice Grading Program

  1. #1
    Registered User
    Join Date
    Nov 2010

    Exclamation Help Needed Fast! Multiple Choice Grading Program

    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!


    #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;;
    	cout << "Enter the name of the output file." << endl;
    	cin >> outFileName;;
    	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";
    		check = false;
    	for (int count = 0; count < key.length(); count++)
    	if( answers[count] == key[count] )
    	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";
    		outFile << grade;
    outFile << endl;
    Last edited by namyad; 11-16-2010 at 02:55 PM.

  2. #2
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Liverpool UK
    it compiles ok for me apart from warnings about comparison of signed and unsigned ints, can you post a sample file to run it with?
    Thought for the day:
    "Are you sure your sanity chip is fully screwed in sir?" (Kryten)
    FLTK: "The most fun you can have with your clothes on."

    "If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    Does it matter?
    They wanted it "in 2 hours", and that deadline has long gone.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help needed (problem with basic C program)
    By EpicYuzer in forum C Programming
    Replies: 15
    Last Post: 11-11-2010, 05:38 PM
  2. Replies: 2
    Last Post: 09-16-2009, 06:00 AM
  3. Program Plan
    By Programmer_P in forum C++ Programming
    Replies: 0
    Last Post: 05-11-2009, 01:42 AM
  4. Help needed with program - urgent thanks!
    By lildevil in forum C Programming
    Replies: 1
    Last Post: 03-09-2008, 06:45 AM
  5. fopen();
    By GanglyLamb in forum C Programming
    Replies: 8
    Last Post: 11-03-2002, 12:39 PM