Topic: Should get(char&) set eofbit at EOF?
Author: khurram@metrowerks.com (Khurram Qureshi)
Date: 1995/07/25 Raw View
Martin,
Per section 27.6.1.3 of the ANSI C++ draft (in a nutshell):
1) basic_istream<charT,traits>& get(char_type&c);
effects: if it fails, calls setstate(failbit).
2) basic_istream<charT,traits>& get(char_type* s, streamsize n, char_type
delim = traits::newline());
effects: if it fails, calls setstate(eofbit).
If you have any further questions/comments please contact me directly at:
khurram@metrowerks.com
Thank you
Khurram Qureshi
Metrowerks, Corp.
In article <martinf-2307951632260001@slip204x.slip.colostate.edu>,
martinf@lamar.colostate.edu (Martin Ferguson) wrote:
> Greetings all,
>
> I have just been informed that get(char&) is not supposed to set eofbit
> when it reads the end of file. Only the get(char* buf, int limit, char
> delim =
> '\n') operation should set the eofbit. Is this true, and, if so, what is
> the rationale for this?
>
> This just caused me a headache because get(char&) DOES set eofbit on an
> IBM/AIX/xlC, on SUN/Solaris/GNU g++, and on a Mac/Symantec C++ 7. But NOT
> on a Mac/Metrowerks CW6, which, of course, is where I really want the
> program to work.
>
> Thanks, Martin
Author: martinf@lamar.colostate.edu (Martin Ferguson)
Date: 1995/07/23 Raw View
Greetings all,
I have just been informed that get(char&) is not supposed to set eofbit
when it reads the end of file. Only the get(char* buf, int limit, char
delim =
'\n') operation should set the eofbit. Is this true, and, if so, what is
the rationale for this?
This just caused me a headache because get(char&) DOES set eofbit on an
IBM/AIX/xlC, on SUN/Solaris/GNU g++, and on a Mac/Symantec C++ 7. But NOT
on a Mac/Metrowerks CW6, which, of course, is where I really want the
program to work.
Thanks, Martin