ram
11/19/2008 11:24:00 AM
Carl Forsman <fatwallet951@yahoo.com> writes:
>inputFile.seekg(0, std::ios::end);
In ISO/IEC 9899:1990:
»A binary stream need not meaningfully support
fseek calls with a whence value of SEEK_END.«
Footnote 225 even mentions »undefined behavior«:
»225) Setting the file position indicator to end-of-file,
as with fseek(file, 0, SEEK_END), has undefined behavior
for a binary stream (because of possible trailing null
characters) or for any stream with state-dependent
encoding that does not assuredly end in the initial shift
state.«
In ISO/IEC 14882:2003(E), »seekg« and »tellg« seem to be
defined using »pubseekoff«, which seems to be based on
»seekoff«, which seems to be based on »::std::fseek«,
for which the above quotation from ISO/IEC 9899:1990 applies.