error expected primary-expression before ')' token

This is the beginning of my code. I am rebuilding as I go along. I am stuck getting the error "error expected primary-expression before ')' token". This error occurs down at lines 45-48, when I am attempting to call the functions. I don't want to get to far and then have more to work over. Any input would be greatly appreciated.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
  #include <iostream>
#include <fstream>
#include <string>
#include <iomanip>



using namespace std;
struct studentType
{
	string studentFName;
	string studentLName;
	int testScore[100];
	char grade[5];

};


void readData (ifstream& inFile, struct studentType );
void assignGrade (struct studentType);
int findHighestScore (struct studentType );
void print(ofstream& outFile, struct studentType);

int main()
{
ifstream inFile;
ofstream outFile;
const int SIZE = 20;
studentType students[SIZE];

inFile.open("Ch9_Ex2Data.txt");
{
	if(!inFile)
	cout << "Cannot open file"<< endl;
	return 1;	
}

outFile.open("Ch9_Ex2Out.txt");
{

	if(!outFile)
	cout << "Cannot open file" << endl;
	return 1;
}
readData(inFile, studentType);
assignGrade(studentType);
findHighestScore (studentType);
print(outFIle, studentType);	


system ("PAUSE");
return 0;
}

Last edited on
print(outFIle, studentType);
Typo?^^^^^
yes, thank you. I am still encountering an error though??
You are passing studentType (a type) as argument but the functions expect a studentType object.
ames1951 wrote:
I am still encountering an error though??

That is a not a very helpful statement. Would you like to be more specific?


Amongst other things:
(1) You haven't defined any of readData(), assignGrade(), findHighestScore(), print(), so you can't call them from your program. Comment them out until you have written them.

(2) As it stands these statements look like a mishmash of function declarations and function calls, with arguments that are a mix of variable names and variable types. Consider
readData(inFile, studentType);
inFile is a local variable. studentType is a variable type. Notice a problem? Also, assuming you want the entire students[] array, your prototype will have to reflect the desire to pass an array, not a scalar. Until you write that function your linker will be unhappy.

(3) On line 48 outFIle isn't the name of anything (watch out for upper case/lower case).

(4) Your bracketing is wrong - and not helped by your indenting - on testing the validity of your input/output streams. For example, lines 31 to 36 are equivalent to:
1
2
3
4
5
6
inFile.open("Ch9_Ex2Data.txt");
if(!inFile)
{
   cout << "Cannot open file"<< endl;
}
return 1;	// so it will return without doing anything anyway. 

Similarly with the output stream.

(5) Your indenting (or lack, or inconsistency, of it) is extremely confusing.
Last edited on
Topic archived. No new replies allowed.