I am getting error messages and I dont know what they mean...

  • (2 Pages)
  • +
  • 1
  • 2

19 Replies - 566 Views - Last Post: 14 May 2012 - 08:24 PM Rate Topic: -----

#1 dbaby  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 12-May 12

I am getting error messages and I dont know what they mean...

Posted 14 May 2012 - 04:02 PM

I am getting these messages and I dont know what they mean does anyone know what the messages are trying to tell me??

Error 1 error LNK2019: unresolved external symbol "double __cdecl letterGrade(double * const,double)" (?letterGrade@@YANQANN@Z) referenced in function _main F:\CMPSC125\NewProject\NewProject\FinalPart2.obj NewProject

Error 2 error LNK1120: 1 unresolved externals F:\CMPSC125\NewProject\Debug\NewProject.exe 1 1 NewProject

Any idea where I should look or any suggestions??

I can show my program and assignment if needed. I have been messing with this program all day and I can't seem to get read of the messages..

Is This A Good Question/Topic? 0
  • +

Replies To: I am getting error messages and I dont know what they mean...

#2 Oler1s  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1395
  • View blog
  • Posts: 3,884
  • Joined: 04-June 09

Re: I am getting error messages and I dont know what they mean...

Posted 14 May 2012 - 04:20 PM

> error LNK2019

This can be Googled. MSDN is the authorative reference: see MSDN's explanation.

> unresolved external symbol

You've referred to something, that you say exists somewhere. In this case, you've stated that letterGrade is a function

> "double __cdecl letterGrade(double * const,double)"

Code description of the symbol, showing that it is a function.

> (?letterGrade@@YANQANN@Z)

Actual symbol name, after translation by the compiler. All those funny letters are part of VC++'s name mangling scheme.

> referenced in function _main

That's where you referred to the function. In your main function.
Was This Post Helpful? 1
  • +
  • -

#3 dbaby  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 12-May 12

Re: I am getting error messages and I dont know what they mean...

Posted 14 May 2012 - 04:35 PM

could it be that Im not calling it in the right spot in main? and just so you can see what Ive
done here is my code:

#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;

void readFile(int[], double[]);
double averageScore(double[], int, double);
double highestScore(double[], int, double highScore);
void outReport(int[], double[], int, double, double, char&);
double letterGrade(double [], double);



int main()
{
	
	const int LIMIT = 100;
	int idNum[LIMIT];
	double testScores[LIMIT];
	int numStudents = 0;
	double aveScore = 0.0;
	double highScore = 0.0;
	char grade = ' ';
	

	readFile(idNum, testScores);
	averageScore(testScores, numStudents, aveScore);
	highestScore(testScores, numStudents, highScore);
	outReport(idNum, testScores, numStudents, aveScore, highScore, grade);
	letterGrade(testScores, aveScore);




	system("pause");
	return 0;

}

void readFile(int idNum[], double testScores[])
{
	
	ifstream inFile;
	inFile.open("F://CMPSC125//final1.txt");
	if (!inFile)
	{
		cout << "Error opening input file" << endl;
		inFile.close();		
	}
	
	const int LIMIT = 100;
	for (int numStudents = 0; numStudents < LIMIT; numStudents++)
	{
		inFile >> idNum[numStudents];
		inFile >> testScores[numStudents];			
	}

	inFile.close();
}

double averageScore(double testScores[], int numStudents, double aveScore)
{
	
	for(int num = 0; num < numStudents; num ++)
	{
	aveScore = aveScore + testScores[num];
	}
	return aveScore / numStudents;

	
}

double highestScore(double testScores[], int numStudents, double highScore)
{
	//double highScore = testScores[0];
	for(int num = 1; num < numStudents; num ++)
	{
	if (highScore < testScores[num])
	highScore = testScores[num];
	}
	
	return highScore;
		
}

void outReport(int idNum[], double testScores[], int numStudents, double aveScore, double highScore, char& grade)
{
	cout << "Average Score: " << aveScore << endl;
	cout << "Highest Score: " << highScore << endl;
	cout << "ID" << '\t' << "Score " << '\t' << "Grade" << endl;
	
	cout << idNum[numStudents] << '\t' << testScores[numStudents] << '\t' << grade << endl;



}

//char letterGrade(double testScores, int numStudents, double aveScore, char grade)
double letterGrade(double testScores, double aveScore)
{
	char grade = ' ';

	if( testScores >= 20 || testScores >= aveScore)
	return grade = 'A';
	else
		if((testScores >= 10 && testScores < 20) || testScores >= aveScore)
	return grade = 'B';
	else
		if ( testScores < 10)
	return grade = 'C';
	else
		if(( testScores >= 10 && testScores < 20) || testScores < aveScore)
	return grade = 'D';
	else //if( testScores >= 20 || testScores < aveScore)
	return grade = 'F';
	
	//if( testScores >= 20 || testScores >= aveScore) 
		 //grade = 'A';
	//else 
		//if(testScores >= 10 && testScores < 20)
		//grade = 'B';
	//else 
		//if ( testScores < 10)
		//grade = 'C'; 
	//else 
		//if( testScores >= 10 && testScores < 20)
		//grade = 'D';
	//else
		//grade = 'F';


	//return grade;
}



Was This Post Helpful? 0
  • +
  • -

#4 dbaby  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 12-May 12

Re: I am getting error messages and I dont know what they mean...

Posted 14 May 2012 - 04:42 PM

Am I suppose to put my files in the project? my teacher said to use a path to open the file because when I get my program to work I have 2 other files I should be able to test with by removing the name of one file and putting the other and so on.
Was This Post Helpful? 0
  • +
  • -

#5 Oler1s  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1395
  • View blog
  • Posts: 3,884
  • Joined: 04-June 09

Re: I am getting error messages and I dont know what they mean...

Posted 14 May 2012 - 04:51 PM

> could it be that Im not calling it in the right spot in main?
> Am I suppose to put my files in the project?

Why are you making wild guesses?? Address the observations.

> unresolved external symbol

You say it exists. The linker says it can't find it.

So prove the linker wrong and point out specifically in your code where it is.

Where *specifically* is it?
Was This Post Helpful? 0
  • +
  • -

#6 dbaby  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 12-May 12

Re: I am getting error messages and I dont know what they mean...

Posted 14 May 2012 - 04:54 PM

im not trying to make wild guesses I have been at this all day and I done the protype and called it in main so I guess I dont know what it is that the linker isnt finding.
Was This Post Helpful? 0
  • +
  • -

#7 Oler1s  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1395
  • View blog
  • Posts: 3,884
  • Joined: 04-June 09

Re: I am getting error messages and I dont know what they mean...

Posted 14 May 2012 - 04:57 PM

Let's make this simple.

> double letterGrade(double [], double);

You say there exists a function called letterGrade that takes in a double array (parameter 1) and double (parameter 2), to return a double.

> letterGrade(testScores, aveScore);

You call the function letterGrade here. testScore is a double array, and aveScore is a double, just like you said it would exist.

Here's the million dollar question. Ready for it?

On what line number have you created a function called letterGrade, that takes in a double array (parameter 1) and a double (parameter 2), and then returns a double? What line number?

Simple question.

This post has been edited by Oler1s: 14 May 2012 - 04:59 PM

Was This Post Helpful? 1
  • +
  • -

#8 #define  Icon User is offline

  • Duke of Err
  • member icon

Reputation: 1325
  • View blog
  • Posts: 4,551
  • Joined: 19-February 09

Re: I am getting error messages and I dont know what they mean...

Posted 14 May 2012 - 05:09 PM

In readfile you try and read 100 items, but you are using numStudents. You should probably read while the file is still good, and return the number of students found to main.


You could make the constant LIMIT global or pass the value to the functions. Having several versions of the same constant is unusual and confusing.

const int LIMIT = 100;

Was This Post Helpful? 0
  • +
  • -

#9 dbaby  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 12-May 12

Re: I am getting error messages and I dont know what they mean...

Posted 14 May 2012 - 05:29 PM

I am not trying to seem slow or anything I have just been going at it all day and I seem to keep doing thinks wrong. Ok if this makes any since I want a limit of 100 possible data places but in my file there will be no more than 21 to process and I need to count the number of students but I dont have to cout the number of students I believe its just to show how many times I process.
thanks for help and not talking to me like im slow I am just lost.



#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;

void readFile(int[], double[]);
double averageScore(double[], int, double);
double highestScore(double[], int, double highScore);
void outReport(int[], double[], int, double, double, char&);
char letterGrade(double [], double, int, char&);



int main()
{
	
	const int LIMIT = 100;
	int idNum[LIMIT];
	double testScores[LIMIT];
	int numStudents = 0;
	double aveScore = 0.0;
	double highScore = 0.0;
	char grade = ' ';
	ifstream inFile;

	
	readFile(idNum, testScores);
	averageScore(testScores, numStudents, aveScore);
	highestScore(testScores, numStudents, highScore);
	
	letterGrade(testScores, aveScore, numStudents, grade);
	outReport(idNum, testScores, numStudents, aveScore, highScore, grade);
	




	system("pause");
	return 0;

}

void readFile(int idNum[], double testScores[])
{
	
	ifstream inFile;
	inFile.open("F://CMPSC125//final1.txt");
	if (!inFile)
	{
		cout << "Error opening input file" << endl;
		inFile.close();		
	}
	
	const int LIMIT = 100;
	
	
	for (int numStudents = 0; numStudents < LIMIT; numStudents++)
	{
		inFile >> idNum[numStudents];
		inFile >> testScores[numStudents];			
	}

	inFile.close();
	
}

double averageScore(double testScores[], int numStudents, double aveScore)
{
	
	for(int num = 0; num < numStudents; num ++)
	{
	aveScore = aveScore + testScores[num];
	}
	return aveScore / numStudents;

	
}

double highestScore(double testScores[], int numStudents, double highScore)
{
	//double highScore = testScores[0];
	for(int num = 1; num < numStudents; num ++)
	{
	if (highScore < testScores[num])
	highScore = testScores[num];
	}
	
	return highScore;
		
}

void outReport(int idNum[], double testScores[], int numStudents, double aveScore, double highScore, char& grade)
{
	cout << "Average Score: " << aveScore << endl;
	cout << "Highest Score: " << highScore << endl;
	cout << "ID" << '\t' << "Score " << '\t' << "Grade" << endl;
	
	cout << idNum[numStudents] << '\t' << testScores[numStudents] << '\t' << grade << endl;



}

char letterGrade(double testScores[], double aveScore, int numStudents, char &grade)
{
	//int numStudents;
	double scores = testScores[numStudents];
	for(int num = 1; num < numStudents; num ++)
	if (scores >= 20 || scores >= aveScore)
	 grade = 'A';
	if((scores >= 10 && scores < 20) || scores >= aveScore)
	 grade = 'B';
	if ( scores < 10)
	 grade = 'C';
	if(( scores >= 10 && scores < 20) || scores < aveScore)
	 grade = 'D';
	if( scores >= 20 || scores < aveScore)
	 grade = 'F';

	return grade;




I have a const int LIMIT = 100; and I thought I was using the numStudents as the count of how much is actually in the file because I only want it to process 21 times or until there isn't any more data in the file. I have it working with no errors at the moment but it is only processing the first line of the file and suggestions on what I doin wrong???
Was This Post Helpful? 0
  • +
  • -

#10 #define  Icon User is offline

  • Duke of Err
  • member icon

Reputation: 1325
  • View blog
  • Posts: 4,551
  • Joined: 19-February 09

Re: I am getting error messages and I dont know what they mean...

Posted 14 May 2012 - 06:03 PM

In your function prototypes you can have parameter names.

eg.

// function prototype
void readFile(int idNum[], double testScores[]);



It helps with seeing errors and understanding the program.


Try printing the numStudents value in readFile(), and also printing it after readFile() in main().
Was This Post Helpful? 0
  • +
  • -

#11 dbaby  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 12-May 12

Re: I am getting error messages and I dont know what they mean...

Posted 14 May 2012 - 06:25 PM

Im going to show you what my intructions are because I dont think im suppose to do that..

Write a program that calculates the results of a test. Sample output is shown below. Each line of input contains a student identification number and a test score. The identification number is a one to nine digit whole number; the test score may contain a decimal point. The input file may contain from zero to fifty students. Write separate functions as follows:

1. The ReadInput() function reads the input file, counts the number of students and stores all the identification numbers and test scores in parallel arrays (2 arrays).

2. The AverageScore() function finds and returns the average test score in the array of test scores; the function does not read any input or write any output.

3. The HighScore() function finds and returns the highest test score in the array of test scores; the function does not read any input or write any output.

4. The OutputReport() function prints the report.

5. The LetterGrade() function is passed two arguments: an individual test score (not an array) and the group average. The function returns the student's letter grade according to this scale:
A = 20 points or more above average
B = 10 or more but less than 20 points above average
C = less than 10 points above or below the average
D = 10 or more but less than 20 points below average
F = 20 points or more below average
6. The main() function simply calls the other functions; main() does not perform any input, calculations, or output. Test your program using each of the provided data files: Write the grade report to cout.

THIS IS THE EXAMPLE OF WHAT THE OUTPUT LOOKS LIKE

Average score = 75.00
Highest score = 100.00
ID SCORE GRADE
100000000 54.00 F
100000001 70.00 C
111111111 65.00 D
200000000 89.00 B
200000001 55.00 F
222222222 72.00 C
300000000 66.00 C
300000003 96.00 A
333333333 50.00 F
400000000 95.00 A
400000001 76.00 C
400000004 85.00 B
444444444 94.00 B
500000000 84.00 C
500000001 80.00 C
500000005 59.00 D
555555555 74.00 C
600000000 61.00 D
600000001 56.00 D
600000006 100.00 A
666666666 94.00 B
Was This Post Helpful? 0
  • +
  • -

#12 #define  Icon User is offline

  • Duke of Err
  • member icon

Reputation: 1325
  • View blog
  • Posts: 4,551
  • Joined: 19-February 09

Re: I am getting error messages and I dont know what they mean...

Posted 14 May 2012 - 06:31 PM

I am just suggesting the course of action as a temporary measure, to check the state of the variables.
Was This Post Helpful? 0
  • +
  • -

#13 dbaby  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 12-May 12

Re: I am getting error messages and I dont know what they mean...

Posted 14 May 2012 - 06:34 PM

o ok I havent used a parameter name before what does it mean? I am in an introduction class.
Was This Post Helpful? 0
  • +
  • -

#14 r.stiltskin  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1833
  • View blog
  • Posts: 4,927
  • Joined: 27-December 05

Re: I am getting error messages and I dont know what they mean...

Posted 14 May 2012 - 07:28 PM

Look. Here's your prototype
double letterGrade(double [], double);


and here's the first line of your function definition
double letterGrade(double testScores, double aveScore)


Do you see a difference?
Was This Post Helpful? 0
  • +
  • -

#15 dbaby  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 12-May 12

Re: I am getting error messages and I dont know what they mean...

Posted 14 May 2012 - 07:30 PM

I fixed all that and posted what I have fixed.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2