ifstream.eof() - end of file is reached before the real end

前端 未结 1 1881
半阙折子戏
半阙折子戏 2020-12-31 16:42

I have a roughly 11.1G binary file where stores a series of the depth frames from the Kinect. There are 19437 frames in this file. To read one frame per time, I use

相关标签:
1条回答
  • 2020-12-31 16:57

    You need to open the stream in binary mode, otherwise it will stop at the first byte it sees with a value of 26.

    ifstream depthStream("fileName.dat", ios_base::in | ios_base::binary);
    

    As for why 26 is special, it's the code for Ctrl-Z which was a convention used to mark the end of a text file. The history behind this was recorded in Raymond Chen's blog.

    0 讨论(0)
提交回复
热议问题