系统调用,将一个文件复=中的内容复制到另一个文件中去
来源:互联网 发布:奥维互动地图mac版 编辑:程序博客网 时间:2024/05/16 07:39
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <errno.h>#define BUFFER_SIZE 1024int main(int argc,char *argv[]){ if(argc != 3) { printf("please input two file:\n");exit(1); } int from_fd; int to_fd; char buffer[BUFFER_SIZE]; from_fd = open(argv[1],O_RDONLY); if(-1 == from_fd) { perror("open from_file error");exit(1); } to_fd = open(argv[2], O_CREAT | O_WRONLY, 0655); if(-1 == to_fd) { perror("open to_file error!");exit(1); } while((read_line(from_fd,buffer,sizeof(buffer))) != -1) { if((write(to_fd,buffer,strlen(buffer))) == -1){ perror("write to_file error"); exit(1);}if((write(to_fd,"\n",1)) == -1){ perror("write data n error"); exit(1);}memset(buffer,0,sizeof(buffer)); } return 0;}
0 0
- 系统调用,将一个文件复=中的内容复制到另一个文件中去
- struts+hibernate 将一个bean中的内容复制到另一个bean中去
- Java-基础 文件操作IO 将文件内容复制到另外一个文件中去
- 复制文件中的内容到另一个文件
- C#将文件中的图片复制到另一个文件中
- 黑马程序员高级视频学习笔记 将一个系统盘中的文件复制到另一个系统盘中
- 键盘录入两个文件路径,将其中一个文件夹中的所有的文件复制到另一个文件中
- SQL将一个数据库中的一个表复制到另一个数据库中去
- c语言初步经典题16---将一个文件的内容复制到另一个文件里面
- dos下将多个文件中的内容复制到一个文件中
- 复制两个文件中的内容到一个文件中
- [Linux] 复制一个文件的内容到另一个文件
- 在linux中如何把2个文件中的内容合到另一个文件中去?
- java IO编程——复制一个文件中的内容到另一个文件
- java 从一个文件中读取内容 复制到 另一个文件中
- 将一个文件的内容添加到另一个文件里面
- 将一个文件的内容写入到另一个文件
- vim中如何将一个文件的内容拷贝到另一个文件中
- Andriod: 去掉系统自带的Activity跳转动画,跳转无动画
- 481. Magical String**
- 不要过度依赖JQuery
- Spark 2.1.0的运行模式
- HP-UX修改MP卡的SNMP团体字
- 系统调用,将一个文件复=中的内容复制到另一个文件中去
- MFC 内存泄漏问题
- 了解jsonp跨域并实现自己的jsonp
- 排序算法0——引言
- C/C++轻松写电脑锁机程序
- Android动画之帧动画实现方式
- MFC 实现保存数据为excel文件格式用那种方法好?
- Codeforces 509E(思维)
- 文章标题