LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-10-2002, 01:21 PM   #1
j-ray
Senior Member
 
Registered: Jan 2002
Location: germany
Distribution: ubuntu, mint, suse
Posts: 1,591

Rep: Reputation: 145Reputation: 145
c++ question


i have a little problem compiling a c++ program:

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

int main() {
char datei[128];
ifstream test;
cout <<"Dateiname: "<<flush;
cin.getline(datei,127,'*');
test.open(datei, ios_base::in);
if (test.good())
cout<<"Datei existiert!" << endl;
else
cout <<"Datei ist nicht da!"<<endl;
return 0;
}

The error-message it gives me is:
'ios_base' undeclared
The strange thing is that i ran the program successfully on my old box. i took the code from a book. are there any libraries missing? any explanations or advices?
thanks a lot!
jens
 
Old 05-10-2002, 02:23 PM   #2
Hano
Member
 
Registered: Sep 2001
Location: Venezuela, Caracas
Distribution: RedHat 9.0
Posts: 196

Rep: Reputation: 30
Try this version: note that i just removed the std namespace stuff, and added the .h to the headers, it should compile fine

Hano


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

int main() {
char datei[128];
ifstream test;
cout <<"Dateiname: "<<flush;
cin.getline(datei,127,'*');
test.open(datei, ios_base::in);
if (test.good())
cout<<"Datei existiert!" << endl;
else
cout <<"Datei ist nicht da!"<<endl;
return 0;
}
 
Old 05-10-2002, 02:48 PM   #3
j-ray
Senior Member
 
Registered: Jan 2002
Location: germany
Distribution: ubuntu, mint, suse
Posts: 1,591

Original Poster
Rep: Reputation: 145Reputation: 145
thank you, hano
unfortunately - the error remains the same: 'ios_base' undeclared, parse error before::
 
Old 05-10-2002, 03:02 PM   #4
Hano
Member
 
Registered: Sep 2001
Location: Venezuela, Caracas
Distribution: RedHat 9.0
Posts: 196

Rep: Reputation: 30
what compiler are u using?

Hano
 
Old 05-10-2002, 03:28 PM   #5
j-ray
Senior Member
 
Registered: Jan 2002
Location: germany
Distribution: ubuntu, mint, suse
Posts: 1,591

Original Poster
Rep: Reputation: 145Reputation: 145
g++ version 2.95.3
 
Old 05-10-2002, 03:45 PM   #6
Hano
Member
 
Registered: Sep 2001
Location: Venezuela, Caracas
Distribution: RedHat 9.0
Posts: 196

Rep: Reputation: 30
Ok, i reproduced your error with g++ 2.96.2, it's shouldn't be happening, I compiled it with the intel compiler icc v6.0 and i hadn't errors


Hano
 
Old 05-10-2002, 04:21 PM   #7
j-ray
Senior Member
 
Registered: Jan 2002
Location: germany
Distribution: ubuntu, mint, suse
Posts: 1,591

Original Poster
Rep: Reputation: 145Reputation: 145
i made a couple tests with other programs and everything compiles fine but: ios_base. Well, i guess i can live with that and get myself another compiler in the next days. do you happen to have a recommendation where to obtain that? muchissimas gracias
 
Old 05-10-2002, 04:24 PM   #8
Hano
Member
 
Registered: Sep 2001
Location: Venezuela, Caracas
Distribution: RedHat 9.0
Posts: 196

Rep: Reputation: 30
search in google:
intel icc compiler
there will show up the link to download it


no hay problema.


Hano
 
Old 05-10-2002, 09:53 PM   #9
Sfin
Member
 
Registered: Apr 2002
Location: Michigan
Distribution: Slackware 8.0
Posts: 197

Rep: Reputation: 30
try using ios::in rather than ios_base::in

That might work.
 
Old 05-12-2002, 03:27 PM   #10
j-ray
Senior Member
 
Registered: Jan 2002
Location: germany
Distribution: ubuntu, mint, suse
Posts: 1,591

Original Poster
Rep: Reputation: 145Reputation: 145
would have been nice but this ios::in trick doesn't work. it compiles well but hangs.
cheers jens
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Question, Apples Contribution to Open Source + MacOs file structure question Higgy3k Other *NIX 5 07-25-2005 04:23 AM
Not your regular GRUB question - just a short question for a fried MBR!! ziphem Linux - General 3 01-31-2005 01:51 PM
2 part question: Speeding up MDK9.1/GNOME question wardialer Linux - Newbie 6 10-14-2004 03:16 PM
login prompt question & kde scheme question JustinCoyan Slackware 2 06-09-2004 02:02 PM
RE: Suse 8.0 hardware question {newbie question, pls help} Radiouk Linux - Distributions 2 06-04-2002 12:53 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:33 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration