Sunday, July 28, 2013

std::istream::tellg vs eofbit flag

Newsgroup: comp.lang.c++

Subject: std::istream::tellg vs eofbit flag

From: mathieu <mathieu.malaterre@...>

Date: Thu, 25 Jul 2013 09:41:12 -0700 (PDT)



Hi,



I'd like to check if my understanding of the standard is correct. Is the following program supposed to work ?



$ cat file.cxx

#include <cassert>

#include <fstream>

#include <sstream>



int main ()

{

std::ifstream ifs (__FILE__, std::ios::binary);

std::stringstream ss;



assert (0 == ifs.tellg ());



ifs >> ss.rdbuf ();



assert (ifs.eofbit == ifs.rdstate ());

assert (ifs.eof());

assert (-1 != ifs.tellg ()); // works with g++ 4.4



return 0;

}



I am getting different results using either g++ 4.4 or g++ 4.7.



Thanks.







via Usenet Forums - Usenet Search,Free Usenet - comp.lang.c++ http://www.pocketbinaries.com/usenet-forums/showthread.php?50703-std-istream-tellg-vs-eofbit-flag&goto=newpost

View all the progranning help forums at:

http://www.pocketbinaries.com/usenet-forums/forumdisplay.php?128-Coding-forums

No comments:

Post a Comment