"David Harmon" <so****@netcom.com> wrote in message news:42***************@news.west.earthlink.net...
On Wed, 2 Feb 2005 08:17:00 +0200 in comp.lang.c++, "Alex Vinokur"
<al****@big-foot.com> wrote,while (infile_io.getline (buffer, sizeof(buffer))
{
// Stuff
}
How can one know what was a last character in the stream : newline or EOF?
EOF is not a character.
Theoretically, cin.eof() might tell you what you want to know. But I
wouldn't trust it universally. Why do you care?
Function read_using_io_getline() at
http://groups-beta.google.com/group/...00e587611b957e
produces the same output in two diffrent situations:
1) the file ends by '\n' + EOF;
2) the file ends by EOF without '\n'.
I want the program to produce different output that corresponds to the file content (contene includes '\n'-s too).
----- Fragment of read_using_io_getline() -----
if (infile_io.fail())
{
infile_io.clear (~(ios_base::failbit | ~infile_io.rdst*ate ()));
}
else
{
// Here I would like to know if the file ends by 1) '\n' + EOF or 2) EOF without '\n'.
cout << '\n';
}
-----------------------------------------------
--
Alex Vinokur
email: alex DOT vinokur AT gmail DOT com
http://mathforum.org/library/view/10978.html http://sourceforge.net/users/alexvn