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 10-03-2005, 06:19 AM   #1
Liche
LQ Newbie
 
Registered: Sep 2005
Posts: 5

Rep: Reputation: 0
(quick!) ifstream problem


I'm porting a largeish program from MSVCPP6 into GCC3.2.3 My program has the following function:

Code:
void myClass::load(const char filename[]) {
    ifstream file(filename);
    if (/*conditions*/) load("anotherfilename")
    file.close()
}
i.e. a load function which, under certain circumstances, calls itself recursively to access another file before carrying on. This works fine under VCPP+WinXP, but under GCC+Linux it fails with the second (and subsequent) file openings.

Is this an operating system difference? How do I resolve this problem?

Thanks

Last edited by Liche; 10-03-2005 at 06:20 AM.
 
Old 10-04-2005, 06:55 PM   #2
sirclif
Member
 
Registered: Sep 2004
Location: south texas
Distribution: fedora core 3,4; gentoo
Posts: 192

Rep: Reputation: 30
Quote:
void myClass::load(const char filename[]) {
ifstream file(filename);
if (/*conditions*/) load("anotherfilename")
file.close()
}
well, the one problem i see (aside from missing semicolons), which may only be because you tried to generalize the code for us, is that "anotherfilename" never changes. so if you keep trying to call load and pass it the same string everytime, you'll have already opened the file. like i said, that may not be what is going on, but its the only thing that sticks out at me.
 
  


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
What do these ifstream errors mean please? twirl Programming 5 09-08-2005 07:34 PM
Problems with ifstream/ofstream kornerr Programming 2 07-04-2005 11:31 AM
ifstream - Problem siemens Programming 2 05-13-2005 01:25 PM
ifstream errur ashirazi Programming 1 02-14-2005 04:35 AM
a class with a ifstream member Hano Programming 2 04-24-2002 11:01 AM

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

All times are GMT -5. The time now is 07:18 PM.

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