Why is fread reaching the EOF early?

前端 未结 3 1322
春和景丽
春和景丽 2020-12-06 03:57

I am writing a C library that reads a file into memory. It skips the first 54 bytes of the file (header) and then reads the remainder as data. I use fseek to determine the l

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-06 04:40

    perhaps it's a binary mode issue. Try opening the file with "r+b" as the mode.

    EDIT: as noted in a comment "rb" is likely a better match to your original intent since "r+b" will open it for read/write and "rb" is read-only.

提交回复
热议问题