fread is signalling EOF prematurely with a binary file

老子叫甜甜 提交于 2019-12-06 21:13:45

Are you on Windows? Yes, the pathname starts C: so you are. You've probably got a Control-Z ('\x1A' or '\32') character in the file. It (the Windows C run-time, and hence your program) won't treat standard input as a binary file unless you tweak it somehow, so the Control-Z marks the end of the input.

One possible 'somehow' to tweak the mode is _set_fmode(). However, it is more likely that you need _setmode():

_setmode(fileno(stdin), O_BINARY);

I reserve judgement on whether that's the best or only method for doing so. You can research the manuals as well as I can. I have no way to test that fileno() — or perhaps _fileno() in the Microsoft world — is available.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!