ios::ate in gcc3.4.2

Li Qihong
Wed Dec 22 03:17:00 GMT 2004

Hi, I have question on using ios::ate in fstream

the source as following

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

    fstream f;"1", ios::out | ios::ate);
    f.seekp(0, ios::end);
    f << "Haha";

    return 0;

The file '1' is existed in current directory, its' content is "Merry
Christmas!", I want to add some words in the file(here

is the end of file, but my purpose is adding words in the middle of
file), but when I open file with ios::out | ios::ate,

it will clear the origal content of file '1' as if I open it in
ios::out. This occured in gcc3.4.2, when I use gcc2.9.5, it works

I don't know whether it is a bug in gcc3.4.2 or I use it in wrong way.

Merry Christmas!

Best Wish with You!
			Li Qihong
China Integrated Circuit Design Center
Address: No.1 Gaojiayuan,Chaoyang District,Beijing,China.
Postcode: 100015 P.O.Box 8545
Tel: (86-10)64365577-2104

More information about the Gcc-help mailing list