求c io高手解答

hacqing hacqing 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
今天回来遇到一问题,



//1.txt文件大小为1444byte
//windows :
#include <io.h>

//linux #include <unistd.h>

#include <fcntl.h>
/*#include <stdio.h>*/

int main(void)
{
// FILE * file = fopen("f:/temp/1.txt", "rb");
int fd = 0;
char buff[1024];
int reads = 0;
int counts = 0;
// fd = file->_file;
fd = _open("f:/temp/1.txt", O_RDONLY, 0777);

while ((reads = _read(fd, buff, sizeof(buff))) > 0) {
counts += reads;
}

reads += 0;
return 0;
}
//xp3下vs2008,counts 为1408, ubuntu 12.04下gcc,counts为1444





// #include <io.h>
// #include <fcntl.h>
#include <stdio.h>

int main(void)
{
FILE * file = fopen("f:/temp/1.txt", "rb");
int fd = 0;
char buff[1024];
int reads = 0;
int counts = 0;
fd = file->_file;
// fd = _open("f:/temp/1.txt", O_RDONLY, 0777);

while ((reads = _read(fd, buff, sizeof(buff))) > 0) {
counts += reads;
}

reads += 0;
return 0;
}
//xp3下vs2008,counts 为1444


真心伤不起,以前只是听说window对c标准支持不够,这回不知道是不是这个问题,请各位各抒己见,谢谢。
很久不灌水,分不多。全部家当,哈哈。
...全文

相关推荐

评论 4
收藏 已收藏
分享
返回顶部
hacqing
C语言 70,039 成员 243,237 内容