Topic: tellg vs. tellp


Author: matthewtunapolder@kodak.com (Matthew Polder)
Date: Wed, 23 Jun 2004 22:42:41 +0000 (UTC)
Raw View
Hi,

Consider the following:

std::fstream file("someFile.dat, std::ios::in | std::ios::bin);
long b;
file.read( (char*)&b, sizeof(b) );
long offset = file.tellp();

Using gcc 3.3 on Solaris, the tellp call will set some bit (forgive for
not knowing which one) such that file.good() returns false and offset =
-1. Using Visual Studio 7.1 on Windows 2000, the tellp works and returns
the proper offset. Is the behavior of using tellp on a stream open for
writing undefined, implemenation specific, or what?

thanks,
matthew

--



Please remove the word 'tuna' from my name and add a dot j dot ('.j.')
for my correct email address. If you are a spammer please add the word
"Istink" after the word tuna.

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: sebormartin@netscape.net (Martin Sebor)
Date: Fri, 25 Jun 2004 20:18:25 +0000 (UTC)
Raw View
The standard doesn't require that the function set any bits unless it
catches an exception, so it probably shouldn't set any. FWIW, though,
I don't see any code in gcc 3.3.2 sources that sets any bits under any
conditions (this looks fixed in 3.4), so I'm not sure what's going on
in your program.

Martin

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]