Reading binary istream byte by byte

前端 未结 5 645
迷失自我
迷失自我 2021-01-01 10:57

I was attempting to read a binary file byte by byte using an ifstream. I\'ve used istream methods like get() before to read entire chunks of a binary file at once without a

5条回答
  •  一整个雨季
    2021-01-01 11:30

    The >> extractors are for formatted input; they skip white space (by default). For single character unformatted input, you can use istream::get() (returns an int, either EOF if the read fails, or a value in the range [0,UCHAR_MAX]) or istream::get(char&) (puts the character read in the argument, returns something which converts to bool, true if the read succeeds, and false if it fails.

提交回复
热议问题