This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Repositioning fstream


Hi,

Chances are I'm wrong, but shouldn't this code print "wibble" on stdout ?

#include <fstream>
#include <iostream>

int main()
{
    std::fstream f("/tmp/tmp.txt", std::ios::in|std::ios::out|std::ios::trunc);
    f << "wibble" << std::endl;
    f.seekg(0);
    std::cout << f.rdbuf();
}

It does print "wibble" using GCC 2.95 and 3.3, but not 3.4 or 4.0.

I know you have to reposition an fstream between reads and writes - but
I thought that's what the seekg() did, isn't it?

Am I using some broken form that was removed for 3.4, or is it a bug?

If it should work I'll look into it further, I just wanted to check
first.

jon


-- 
"Live fast, die old, and make very sure everyone knows you were there."
	- Alan Cox


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]