分享

C语言文件复制

 orion360doc 2011-10-18
关键问题在于:feof和读函授fgetc的次序,因为会影响feof的行为,
请看msdn中原文:
For example, if a file contains 10 bytes and you read 10 bytes from the file, feof will return 0 because, even though the file pointer is at the end of the file, you have not attempted to read beyond the end. Only after you try to read an 11th byte will feof return a nonzero value.
也就是说,虽然,文件指针到达文件尾部,但是,如果没有读操作,feof也会返回0,所以,只有到达文件尾部并且有读操作发生后,feof才返回非零值,这是问题的关键和本质。

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多