This is the mail archive of the
mailing list for the libstdc++ project.
- From: Jonathan Wakely <cow at compsoc dot man dot ac dot uk>
- To: libstdc++ at gcc dot gnu dot org
- Date: Fri, 7 Jan 2005 16:27:35 +0000
- Subject: Repositioning fstream
- References: <20050107150822.GA75406@compsoc.man.ac.uk>
Chances are I'm wrong, but shouldn't this code print "wibble" on stdout ?
std::fstream f("/tmp/tmp.txt", std::ios::in|std::ios::out|std::ios::trunc);
f << "wibble" << std::endl;
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
"Live fast, die old, and make very sure everyone knows you were there."
- Alan Cox