Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error in include

Status
Not open for further replies.

olatzcelaya

Programmer
Jan 4, 2008
13
0
0
GB
HI everyone,

I need your help in the error that this code gives me:

#include <iostream.h>
#include <fstream.h>
#include <stdlib.h>

int main ()
{
ofstream outClientFile ( "clients.dat", ios::eek:ut ) ;

if (!outClientFile)
{
cerr << "File could not be opened" << endl;
exit (1);
}

cout << "Enter the account, name, and balance.\n " ;

int account;
char name [30];
float balance;

while ( cin >> account >> name >> balance )
{
outClientFile << account << ' ' << name << ' ' << balance << '\n' ;
cout << "?";
}

return 0;

}


The error is the following one and appears in the lines of the include:

C:\Dev-Cpp\include\c++\3.4.2\backward\iostream.h:31, from .\Mis documentos\Practicas C\sequential access file.cpp In file included from C:/Dev-Cpp/include/c++/3.4.2/backward/iostream.h:31, from ../Mis documentos/Practicas C/sequential access file.cpp

Could anybody tell me why this error appears????? Any help will be appreciated.


Thanks a lot,


Olatz
 
<iostream.h> and <fstream.h> are old, non-standard headers that don't work in many modern compilers. The new and correct versions are <iostream> and <fstream>.

The new versions put everything into the std namespace. You should do a little research on what that means, but for starters a simple way to handle that issue is to add using namespace std; on a line below your #includes.

Those changes should allow your program to compile and run.

After you get it working, you should look at wherever you got that code and see if you should continue with that source. Learning out of date practices and tools will make improving harder. Not only are the headers outdated, but that code also uses C style strings which should be probably be changed to C++ strings.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top