C equivalent to fstream's peek

前端 未结 3 590
无人共我
无人共我 2020-11-30 11:13

I know in C++, you\'re able to peek at the next character by using: in.peek();.

How would I go about this when trying to \"peek\" at the next character

3条回答
  •  感情败类
    2020-11-30 11:19

    you'll need to implement it yourself. use fread to read the next character and fseek to go back to where you were before the read

    EDIT:

     int fsneaky(FILE *stream, int8_t *pBuff, int sz) {
        sz = fread(pBuff, 1, sz, stream)
        fseek(pFile, -sz, SEEK_CUR);
        return(sz);
     }
    

提交回复
热议问题