| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 626 人关注过本帖
标题:write真能返回一个非负的却小于写入长度值的整数吗?
只看楼主 加入收藏
vfdff
Rank: 6Rank: 6
等 级:侠之大者
威 望:8
帖 子:2172
专家分:425
注 册:2005-7-15
结帖率:79.17%
收藏
已结贴  问题点数:10 回复次数:2 
write真能返回一个非负的却小于写入长度值的整数吗?
MSDN对_write返回值的解释
If successful, _write returns the number of bytes actually written. If the actual space remaining on the disk is less than the size of the buffer the function is trying to write to the disk, _write fails and does not flush any of the buffer’s contents to the disk. A return value of –1 indicates an error. In this case, errno is set to one of two values: EBADF, which means the file handle is invalid or the file is not opened for writing, or ENOSPC, which means there is not enough space left on the device for the operation.
在我的理解:返回值分三类
1: -1 写入错误
len: 正确的完整写入文件
(0,len) 但是在0到len之间的数值代表什么意思呢?我一直没有像明白,或者是我英语不好,对这个理解错误了?
搜索更多相关主题的帖子: 整数 write 长度 
2010-07-10 19:38
hao0716
Rank: 4
等 级:业余侠客
威 望:1
帖 子:353
专家分:222
注 册:2006-4-11
收藏
得分:10 
这段只是说如果磁盘空间不够则write失败不会flush buffer到硬盘
返回值fbadf表示文件句柄错误或者文件不是以写形式打开的
enospc表示磁盘无足够空间去写这个buffer
不会出现0-len的情况

2010-07-10 21:14
vfdff
Rank: 6Rank: 6
等 级:侠之大者
威 望:8
帖 子:2172
专家分:425
注 册:2005-7-15
收藏
得分:0 
谢谢了,俺看来要学习英语了!

~~~~~~~~~~~~~~~好好学习~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2010-07-13 23:13
快速回复:write真能返回一个非负的却小于写入长度值的整数吗?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.012009 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved