Windows read()函数?

tujie1899 2008-04-01 02:59:02
请问Windows下有read()和write()函数吗?
...全文
1121 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
cainiaohhf 2012-03-09
  • 打赏
  • 举报
回复
windows 下面应该是_read,_write吧(具体可以看msdn)。其中,里面的fd是有个限制的,最大是32.socket函数产生的fd是不能用于read、write的,因为一般都是大于32的。
bestvalentine 2008-04-01
  • 打赏
  • 举报
回复
mark
bestvalentine 2008-04-01
  • 打赏
  • 举报
回复
up
  • 打赏
  • 举报
回复
《windows系统编程》这个书里讲的很多
  • 打赏
  • 举报
回复
CreateFile
ReadFile
WriteFile
lanmuyi 2008-04-01
  • 打赏
  • 举报
回复
函数名: read
功 能: 从文件中读
用 法: int read(int handle, void *buf, int nbyte);
程序例:

#include <stdio.h>
#include <io.h>
#include <alloc.h>
#include <fcntl.h>
#include <process.h>
#include <sys\stat.h>

int main(void)
{
void *buf;
int handle, bytes;

buf = malloc(10);

/*
Looks for a file in the current directory named TEST.$$$ and attempts
to read 10 bytes from it. To use this example you should create the
file TEST.$$$
*/
if ((handle =
open("TEST.$$$", O_RDONLY | O_BINARY, S_IWRITE | S_IREAD)) == -1)
{
printf("Error Opening File\n");
exit(1);
}

if ((bytes = read(handle, buf, 10)) == -1) {
printf("Read Failed.\n");
exit(1);
}
else {
printf("Read: %d bytes read.\n", bytes);
}
return 0;
}
Supper_Jerry 2008-04-01
  • 打赏
  • 举报
回复
看msdn 有的。

69,369

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧