Click to See Complete Forum and Search --> : appending to a file in c++


saai
10-12-2000, 11:15 PM
I am porting a function that appends text to a file, in c++.
In windows, the following code compiles and works perfectly:
ofstream fout("hi.txt", ios_base::app);
But in linux, g++ barfs and says ios_base is not specified/defined. I have both iostream and fstream included in the linux port as well as the windows port, and am using namespace std.
Anyone know the equivalent of ios_base in linux or what i am doing wrong?

thanks,

saai

Glaurung
10-13-2000, 03:29 PM
Try ios::app instead of ios_base::app . I don't know if it works, though. (At least, I haven't tried)

Strike
10-13-2000, 04:47 PM
Yes, using ios instead of ios_base will fix it. But, ios_base should work, hmmm...

saai
10-13-2000, 10:27 PM
thanks a lot, using ios works.
i think thats strange, since my c++ book (c++ primer plus) says to use ios_base as well.