免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12
最近访问板块 发新帖
楼主: SanZhiYuan
打印 上一主题 下一主题

[函数] fclose()的问题 [复制链接]

论坛徽章:
0
11 [报告]
发表于 2009-03-30 13:04 |只看该作者

回复 #5 zhuhefang2006 的帖子

fclose失败是要改 errno的值的

  1. RETURN VALUE
  2.        Upon  successful  completion 0 is returned.  Otherwise, EOF is returned
  3.        and the global variable errno is set to indicate the error.  In  either
  4.        case  any  further  access  (including another call to fclose()) to the
  5.        stream results in undefined behavior.
复制代码

论坛徽章:
0
12 [报告]
发表于 2009-03-30 14:04 |只看该作者
奇怪………………

论坛徽章:
0
13 [报告]
发表于 2009-03-30 23:29 |只看该作者
原帖由 SanZhiYuan 于 2009-3-9 11:03 发表
为什么我调用了fclose()以后返回值不是0但是errno的值是success呢?

你确定fclose之后没有调用其它系统命令?

论坛徽章:
0
14 [报告]
发表于 2009-03-31 09:59 |只看该作者
这种实验用C++做基本上是自找麻烦。
谁知道析构的时侯有没有调free()...

用C!

论坛徽章:
0
15 [报告]
发表于 2009-03-31 23:06 |只看该作者
fclose()是有可能失败的,因为要把缓冲区的数据实际写入文件
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP