Problems with fstream library.

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Netaro
Posts: 5
Joined: Fri Feb 09, 2007 10:27 pm

Problems with fstream library.

Post by Netaro »

Hello!
Well, i tried to use the fstream library along with the irrlicht to try making some save game function. But, i noticed that there are some problems with the fstream. I included fstream, then i tried to make...

Code: Select all

ofstream Plik;
Plik.open("test.txt");
Plik << "test" << std::endl;
Plik.close();
Same problems with fstream & ifstream. Errors are->

Code: Select all

19 C:\Dev-Cpp\irr\main.cpp `ofstream' undeclared (first use this function) 
19 C:\Dev-Cpp\irr\main.cpp expected `;' before "Plik" 
23 C:\Dev-Cpp\irr\main.cpp `Plik' undeclared (first use this function) 
So, is there any solution to this problem?
Using Dev-cpp 4.9.9.2.
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

All classes in the iostreams library are in the std namespace. The easy fix would be to put a using namespace std; at the top of the file. Another solution would be to explicitly say which namespace the classes are in, like this...

Code: Select all

std::ofstream Plik;
//...
Travis
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

it's in the std namespace, you need to use

Code: Select all

std::ofstream Plik;
by the way, I'd advise against using dev-cpp, as it's been out of development for over a year. If you're an open source fanatic, code::blocks nightly builds are much more up to date.
Myself I prefer Microsoft's Visual C++ 2005 Express (free version, unlike some people here I have no moral objections to using Microsoft apps ;) ), as the debugger is the best I've ever seen and very easy to use, it can debug inside Irrlicht.dll.

edit: damn! too slow!
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

it is matter of personal preference. I use DevC++ since I started to code in C++ and like it a lott.

bitplane >> from where do you know that its out of development for over one year? Not that I play close attention to it but last beta version (4.9.9.2) is not more than year old ...at last I think... I am going to have a look at their web page probably...

...you right it is from 5. November 2005
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

the sole reason I use Visual C++:
Image

I used Dev-cpp for a long time, the profiler is good but debugging sucks. you can't debug inside DLLs (or at least I never worked out how to), it has a habbit of skipping over breakpoints, and it hangs randomly. Debugging with printfs is painstakingly slow.

I've not got the hang of codeblocks yet so I can't really comment on it. I will switch if/when it can offer me something like what you see above.
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
Post Reply