如何将不用系统函数将一个文本复制
2017-08-07 09:28
176 查看
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include<errno.h>
#include <unistd.h>
#define SIZE 1024
int main ()
{
int fd1=open ("1.ppt",O_RDONLY);
if (fd1==-1)
{
perror("open fd1");
}
int fd2=open("2.ppt",O_WRONLY|O_CREAT,0777);
if (fd1==-1)
{
perror("open fd2");
}
int ret=0;
char buf [SIZE]={0};
while (ret=read(fd1,buf,SIZE))
{
if (ret ==-1)
{
perror("read");
break;
}
write (fd2,buf ,ret);
}
printf ("fuzhiwancheng\n");
close(fd1);
close(fd2);
return 0;
}
#include <fcntl.h>
#include <stdio.h>
#include<errno.h>
#include <unistd.h>
#define SIZE 1024
int main ()
{
int fd1=open ("1.ppt",O_RDONLY);
if (fd1==-1)
{
perror("open fd1");
}
int fd2=open("2.ppt",O_WRONLY|O_CREAT,0777);
if (fd1==-1)
{
perror("open fd2");
}
int ret=0;
char buf [SIZE]={0};
while (ret=read(fd1,buf,SIZE))
{
if (ret ==-1)
{
perror("read");
break;
}
write (fd2,buf ,ret);
}
printf ("fuzhiwancheng\n");
close(fd1);
close(fd2);
return 0;
}
相关文章推荐
- 在EXCEL中如何让一列数字变成文本格式?就是想让单元格的左上角变一个绿绿的?
- vc中如何将一个工程的资源复制到另外一个工程【转】
- 在知乎复制的文本为什么会自带一些版权声明,这个功能是如何实现的?
- 如何把一个Array 复制到ArrayList中?
- 网页上的文本无法复制?一个代码即可帮你突破限制,秒学!
- 如何把一个文本列表添加到 TListBox 并避免重复项 - 回复 "xnlxw" 的问题
- 将C盘一个文本文件复制到D盘
- [Java技巧] 如何复制数组的一部分到另外一个数组?
- 如何以编程方式将一个 IMG 元素复制到剪贴板
- 如何过一个不用愤“痘”的夏天
- js中如何复制一个对象,如何获取所有属性和属性对应的值
- SQL中如何将一个表中的某一列的数据复制到另一个表中的某一列里
- 如何不用那么担心成为一个坏程序员
- 杨辉三角,一个vector实现,不复制,不用队列。
- 如何不用那么担心成为一个坏程序员
- SQL : 如何完全复制一个服务器上的数据库A到另一个服务器上的数据库B(包括库A的所有表、试图、存储过程等等)
- 复制一个web项目,项目名称如何修改,才能保证项目正常运行
- 如何将网页复制过来的表格变成文本
- 如何将一个文本文件中的数据加载到oracle数据库中
- 如何把一个TXT文本文件按行数分割成多个文本文件