write and read
来源:互联网 发布:淘宝情报通 编辑:程序博客网 时间:2024/04/30 14:19
int my_write(int fd,void *buffer,int length)
{
int bytes_left;
int written_bytes;
char *ptr;
ptr=buffer;
bytes_left=length;
while(bytes_left>0)
{
/* 开始写*/
written_bytes=write(fd,ptr,bytes_left);
if(written_bytes<=0) /* 出错了*/
{
if(errno==EINTR) /* 中断错误 我们继续写*/
written_bytes=0;
else /* 其他错误 没有办法,只好撤退了*/
return(-1);
}
bytes_left-=written_bytes;
ptr+=written_bytes; /* 从剩下的地方继续写 */
}
return(0);
}
{
int bytes_left;
int bytes_read;
char *ptr;
bytes_left=length;
while(bytes_left>0)
{
bytes_read=read(fd,ptr,bytes_read);
if(bytes_read<0)
{
if(errno==EINTR)
bytes_read=0;
else
return(-1);
}
else if(bytes_read==0)
break;
bytes_left-=bytes_read;
ptr+=bytes_read;
}
return(length-bytes_left);
}
- Read and Write XML
- Read and Write Excel
- file read and write
- write and read
- read and write files
- Python read and write
- read and write binary xml
- Read and write bytes data
- Read and Write File Code
- read and write '.bmp' file
- QT之write and read
- IO read and write. demo
- plist --- 's read and write
- Read and Write XLS in Java - JXLS
- [zz] Read and write a properties file
- file read and write use java
- LINQ join and CSV read/write
- Read and Write a /proc File
- Asp.net C# 获取本周上周本月上月本年上年第一天最后一天时间大全
- windows server 2003 普通用户(users)远程登录立即自动注销的解决方法
- linux 下chattr 用法参数说明
- 第十四周上机任务----动物的叫声
- 快速排序(C++)
- write and read
- DIOCP开源项目-DEMO(怎么样操作远程数据库)
- 第14周C++上机报告(Animal抽象基类)
- 时钟电路设计概述 - 数字电路设计
- svn pom文件基础设置
- 查看mysql分区表具体情况
- 屏蔽ecshop2.7.3的云提示no_license
- 安卓手机短信、通话记录、通信录删除了怎么恢复
- 图片二进制互相转换C#