Saturday, April 7, 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

plot explanation - Why did Peaches&#39; mom hang on the tree? - Movies &amp; TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...