What does the error message mean?

1>Linking...
1>grading.obj : error LNK2019: unresolved external symbol "int __cdecl check_correct_answers(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,char,double)" (?check_correct_answers@@YAHV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0DN@Z) referenced in function _main
1>C:\Users\Documents\Visual Studio 2008\Projects\grading\Debug\grading.exe : fatal error LNK1120: 1 unresolved externals

Unresolved external means the variable being used does not exist. It was never defined at the spot you are attempting to use it.

Ok thanx m8.
A rather silly question i've got:

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

using namespace std;

int check_correct_answers ( string answerKey, string studentAnswers, char grade, int score); 
char display_student_grade( int score);

int main()
{

	ifstream inFile;
    ofstream outFile;

    inFile.open ("tftest.txt");
    outFile.open ("testout");

	int score=0;
    char grade;   
  
   string answerKey;
   string studentID;
   string studentAnswers;

   getline(inFile, answerKey);

   cout<<"The correct answers "<<answerKey << endl<<endl;
   while(getline(inFile, studentID))
   {
     cout << studentID <<" ";

     getline(inFile, studentAnswers);
     cout << studentAnswers << endl;
   }
   display_student_grade(score);
   check_correct_answers(answerKey,studentAnswers,grade,score);   

	return 0;
}
   int check_correct_answers( string answerKey, string studentAnswers,char grade,int score)
   {

  int i, correct = 0, incorrect = 0, blank = 0;

  for (i = 0; i < 23 - 1; i++)
  {
        if (answerKey[i] == studentAnswers[i])
            correct++;
        if (answerKey[i] != studentAnswers[i])
            incorrect++;
        if (studentAnswers[i] == ' ') 
		{
            blank++;
            incorrect--;
        }
        score = (correct * 5) + (incorrect * (-2)) + (blank *( -4));
  }
  cout << score << endl;
  return score;
   }

// PRINT OUT STUDENT GRADES
char display_student_grade( int score ) 
{
	int i;
    for (i = 0; i < 30; i++) 
	{
        if (score >= 90)
            cout<<"A"<<endl;     
        else if (score < 90 && score > 79)
            cout<< "B"<<endl;
        else if (score <= 79 && score > 69)
            cout<< "C"<<endl;
        else if (score <= 69 && score > 60)
            cout<< "D"<<endl;
        else if (score <= 59)
            cout<< "F"<<endl;
    }
    return 0;
}

My output:

The correct answers TFFTFFTFFTFFTFTFTFTFFF

A33 TFFTFFTFFFFFTFTFTFFFFT
Z27 TFFTFFTFFTFFTFTFTFTFFT
X12 TFTT FTFFTFFFT FTFTFFF
H44 TFFTFFTFFTFFFFTFTFFTFF
Q19 FFFFFFFFFFFFTFTFTFFFFF
D72 TFFTFFTFFTFF FFFFFTFFF
W32 FFFTFFTFFTFFTFTFTFFTTT
Y09 TFFTFFTFFTFFTFFTTFFTTT
S44 TFFTFFTFFTFFTFTFTFTFFF
G11 FFTFFTFFTFFTFTFTTFTFFF
J21 TFFTFFFFFTFFTFTFTFTFTT
K61 TFFTFFTFFTFFTFTFTFTFT
M03 TFFTFFTFFFFFTFTFTFTFFT
P24 TFFTFFTFFTFFTFTFTFFFFT
N54 FTFFTFFTFT TFF FTFTFFF
F33 TFFTFFTFFTFFTFTFTFTFFF
Z21 TFFTFFFTTFTTFFTFTFTFTF
V39 TFFFTTFTTFTTFTFTFTTFFF
O66 TTFTFFTFFTFFTFTFTFTFFF
B29 TFFTFFTFFTFF FFTTFFTFF
J17 TFFTFFFTTTFFTFFTFTFTTT
K09 TFFTFFTFTTFTTFTFTFFTFF
L99  FFTFFTFFTFFFFTFTFTFFF
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
94

It says that grade isn't initialized. Can you initialize a char. I thought our professor said it'sonly for mathematical values? Please clarify for mr please.

You can, and usually should intialize, a char, or any other variable for that matter, before you use it for anything but the target of an assignment statement. Otherwise who knows what value it will have. Since you are displaying the grade from within diplayGrade() function, or whatever you call it, you don't even need a variable called grade, so you can remove it.

You really should put lines 38 and 39 inside the while loop so the functions are called for every students information read from the file, and reverse the call order so you calculate each students score before you determine and display the grade!

If you are going to display the score from within check_correct_answers() then don't go to newline after you display the score.

Don't use a loop to display 30 grades based on a score of zero as your current code does. You will only be displaying one grade at a time as it is generated so it can be displayed on the same line as the student ID, student answers and student score.

commented: breaks down problems good +1

Ok, thx for the feedback.

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

using namespace std;

int check_correct_answers(string answerKey, string studentAnswers);
void display_student_grade(int score);

int main() 
{

    ifstream inFile;
    ofstream outFile;

    inFile.open("tftest.txt");
    outFile.open("testout");

    int score=0;

    string answerKey;
    string studentID;
    string studentAnswers;

    getline(inFile, answerKey);

    cout<<"The correct answers "<<answerKey << endl<<endl;
    while (getline(inFile, studentID)) 
	{
        cout << studentID <<" ";
        getline(inFile, studentAnswers);
        cout << studentAnswers << endl;
        score = check_correct_answers(answerKey, studentAnswers);
        display_student_grade(score);
    }

    return 0;
}
int check_correct_answers(string answerKey, string studentAnswers) 
{

    int i, correct = 0, incorrect = 0, blank = 0;
    int score=0;
    for (i = 0; i < 23 - 1; i++) 
	{
        if (answerKey[i] == studentAnswers[i])
            correct++;
        if (answerKey[i] != studentAnswers[i])
            incorrect++;
        if (studentAnswers[i] == ' ') 
		{
            blank++;
            incorrect--;
        }
        score = (correct * 5) + (incorrect * (-2))+ (blank *( -4));
    }
    cout << score<<" ";
    return score;
}

// PRINT OUT STUDENT GRADES
void display_student_grade(int score) 
{
    if (score >= 90)
    cout<<"A"<<endl;
    else if (score< 90 && score > 79)
	cout<< "B"<<endl;
    else if (score <= 79 && score > 69)
    cout<< "C"<<endl;
    else if (score <= 69 && score > 60)
    cout<< "D"<<endl;
    else if (score <= 59)
    cout<< "F"<<endl;
}

Now it comes out ok....However will i have to create a separate function to calcualte the average for the entire class?
Thx again guys.

The short answer is no. The long answer is you can if you want/need to. If you create another variable to accumulate a running total of scores, initialize it to zero outside the while loop and increment it by each score as it is calculated, you can then divide by the total number of students in the class once all the student information from the file has been read in.

Ok, this is what i tried.I'm trying to calculate the class average and I want it print at the bottom after i've shown the records & grades for the students:

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

using namespace std;

int check_correct_answers(string answerKey, string studentAnswers);
void display_student_grade(int score);
void classAV(double classaverage,int sumgrades, int score);

int main() 
{

    ifstream inFile;
    ofstream outFile;

    inFile.open("tftest.txt");
    outFile.open("testout");

    int score=0;

    string answerKey;
    string studentID;
    string studentAnswers;
    int sumgrades=0;
    double classaverage=0;

    getline(inFile, answerKey);

    cout<<"The correct answers "<<answerKey << endl<<endl;
    while (getline(inFile, studentID)) 
    {
        cout << studentID <<" ";
        getline(inFile, studentAnswers);
        cout << studentAnswers<<" ";
        score = check_correct_answers(answerKey, studentAnswers);
        display_student_grade(score);
        classAV(classaverage,sumgrades,score);
    }

    return 0;
}
int check_correct_answers(string answerKey, string studentAnswers) 
{

    int i, correct = 0, incorrect = 0, blank = 0;
    int score=0;
    for (i = 0; i < 23 - 1; i++) 
    {
        if (answerKey[i] == studentAnswers[i])
            correct++;
        if (answerKey[i] != studentAnswers[i])
            incorrect++;
        if (studentAnswers[i] == ' ') 
        {
            blank++;
            incorrect--;
        }
        score = (correct * 5) + (incorrect * (-2))+ (blank *( -4));
    }
    cout << score<<" ";
    return score;
}

// PRINT OUT STUDENT GRADES
void display_student_grade(int score) 
{
    if (score >= 90)
    cout<<"A"<<endl;
    else if (score< 90 && score > 79)
    cout<< "B"<<endl;
    else if (score <= 79 && score > 69)
    cout<< "C"<<endl;
    else if (score <= 69 && score > 60)
    cout<< "D"<<endl;
    else if (score <= 59)
    cout<< "F"<<endl;
}
void classAV(double classaverage, int sumgrades, int score)
{
    sumgrades = 0.0;
    sumgrades += score;
    classaverage = (sumgrades/23);
    cout<<endl;
    {
    cout<<"The class average is : "<<classaverage<<endl;
    }
}

You seem to have all the right code but it looks like you randomly put it somewhere.

Put line 40 on line 42, and convince yourself why it should go there instead of where it is.

You don't need classaverage as a parameter for classAV---why not?

You shouldn't pass scores to classAV either.

Put line 84 on line 40 and convince yourself why it should go there.

You definitely don't want line 83 at all----why not?

Thx again man. Problem solved and program works like a charm.

hey im new one for programing. can any one intrested to teach me pls contact me and help me in programing.

husvy_123....a few things:
1. Introduce yourself in the Geek lounge.
2. If you have a specific problem-post the code(not on my thread) and the guys here will take a look at it and help you.
3. Daniweb provides tutorials on several topics. You can go to google and search for a specific topic or the tutorials here (which are good).
4. Don't post your personal code/question on someone elses thread unless it's related to the orignal question...you need to start your own thread.
5. Don't post questions and expect an answer right away or any assistance if you don't try. We're all here to help you learn (even though I don't know a lot either)..
6. I reccommend taking a look at the Rules & FAQ for the daniweb forum.

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.