Right arrow symbol causing abrupt end of fread?

为君一笑 提交于 2019-12-04 12:21:46

Your question is oddly relevant as I recently ran into this problem in an application here at work last week!

The ASCII value of this character is decimal 26 (0x1A, \SUB, SUBSTITUTE). This is used to represent the CTRL+Z key sequence or an End-of-File marker.

Change your fopen mode ("In [Text] mode, CTRL+Z is interpreted as an end-of-file character on input.") to get around this on Windows:

fp = fopen(file, "rb"); /* b for 'binary', disables Text-mode translations */

You should open the file in binary mode. Some platforms, in text (default) mode, interpret some bytes as being physical end of file markers.

You're opening the file in text rather than raw/binary mode - the arrow is ASCII for EOF. Specify "rb" rather than just "r" for your fopen call.

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