Re: ios::ate in gcc3.4.2

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Li Qihong,

Do this...
------------------------------
#include <iostream>
#include <fstream>

using std::fstream;
using std::ios_base;

int main()
{
    fstream f;
    f.open("1", ios_base::in | ios_base::out | ios_base::ate);
//  f.seekp(0, ios_base::end); -- unnecessary w/ios_base::ate
    f << "Haha";
    f.close();
}
---------------------------------

You didn't specify the ios_base::in, which will prevent the ios_base::out from performing an ios_base::trunc for you.

Alternatively, you could do...

    f.open("1", ios_base::out | ios_base::app);

...the ios_base::ate is redundant.

Please see p639 of Stroustrup's C++ Programming Language (special edition).

HTH,
--Eljay


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux