Error C2143

R

Rhodrey

I have the following code:

#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
#include <cstdlib>
#include <conio.h>
#include "stdinfo.h"

using namespace std;

//void checkStatus( fstream& );
//int checkGrades( int, int, int, int );

int main()
{
fstream outStudentFile( "data.txt", ios::in | ios::eek:ut );

if ( !outStudentFile ) {
cerr << "File could not be opened for output. " << endl;
exit( 1 );
}

cout << "Please enter the following information in the file. "
<< "Use -1 to end input. " << endl << endl;

studentdata student;

cout << "Please enter ID Number (Enter -1 to end input): ";
cin >> student.idnumber;

while ( ( student.idnumber ) != -1 ) {
cout << "Enter First and Last Names: ";
cin >> student.firstName >> student.lastName;
cout << "Enter Status (I or A): ";
cin >> student.status;
checkStatus ( outStudentFile );
cout << "Enter 4 Grades: " ;
cin >> student.grade >> student.grade1 >> student.grade2
outStudentFile << student.idnumber << " " << student.firstName << "
" << student.lastName
<< " " << student.status << " " << student.grade << " " <<
student.grade1
<< " " << student.grade2 << " " << student.grade3 << '\n';

cout << "\nPlease enter ID Number (Enter -1 to end input): ";
cin >> student.idnumber;
}

outStudentFile.clear();
outStudentFile.close();

return 0;

}

Do you have any idea why I'm getting the following error when
compiling?
Compiling...
sfile.cpp
C:\Documents and Settings\Rhodrey Shaw\My Documents\Data
Structures\sfile.cpp(9) : error C2143: syntax error : missing ';'
before 'using'
Error executing cl.exe.

sfile.obj - 1 error(s), 0 warning(s)
 
A

Alf P. Steinbach

I have the following code:

#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
#include <cstdlib>
#include <conio.h>
#include "stdinfo.h"

using namespace std;

...

Do you have any idea why I'm getting the following error when
compiling?
Compiling...
sfile.cpp
C:\Documents and Settings\Rhodrey Shaw\My Documents\Data
Structures\sfile.cpp(9) : error C2143: syntax error : missing ';'
before 'using'

Apply logic. It's a missing semicolon before the word 'using'.
Where can that be? Most probably in [stdinfo.h], whatever that
header file is.

Btw., in case you don't know, <conio.h> is not a standard C++ header.
 
P

Peter Kragh

Rhodrey said:
Do you have any idea why I'm getting the following error when
compiling?
Compiling...
sfile.cpp
C:\Documents and Settings\Rhodrey Shaw\My Documents\Data
Structures\sfile.cpp(9) : error C2143: syntax error : missing ';'
before 'using'
Error executing cl.exe.

sfile.obj - 1 error(s), 0 warning(s)

As Alf wrote it's probably a missing ';' in the stdinfo.h file, which
probably contains the declaration of the studentdata class:

class studentdata
{
....
}; // remember the ';' here!?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top