This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Repositioning fstream
- 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>
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