Saturday, 7 April 2018

c++ - fstream unix problem in reading

I am trying to read from binary file on UNIX. The file exists and has several data information in it.




The code looks like this:



fstrean fstrHandler;

string strFileName;

char Buf[30000];

fstrHandler.open(strFileName.c_str(), ios::in | ios::binary);


fstrHandler.seekp(0, std::ios_base::beg);

std::cout<< "Posi before read= "<< fstrHandler.tellg()<
fstrHandler.read (Buf, 400);

std::cout<< "Posi after read= "<< fstrHandler.tellg()<
std::cout<< " gcount ()= "<< fstrHandler.gcount ()<< << endl; //*** Show after running 0


if (fstrHandler.eof ()) {
fstrHandler.clear();
}


After the read I get that the position in file is still zero zero, but the file is not empty.

No comments:

Post a Comment

casting - Why wasn&#39;t Tobey Maguire in The Amazing Spider-Man? - Movies &amp; TV

In the Spider-Man franchise, Tobey Maguire is an outstanding performer as a Spider-Man and also reprised his role in the sequels Spider-Man...