\#include<stdio.h\>
\#include<sys/stat.h\>
\#include<sys/types.h\>
\#include<fcntl.h\>
\#include<string.h\>
\#include<unistd.h\>
int main(int argc,char* argv[]){
int src_fd,dst_fd;
int count;
int err;
char* buf[100];
src_fd = open(argv[1],RDONLY);
if(src_fd == -1){
perror("open_error:src");
return 0;
}
dst_fd = open(argv[2],WRONLY|O_CREAT,0666);
if(dst_fd == -1){
perror("open_error:dst");
return 0;
}
while(1){
memset(buf,0,sizeof buf);
count = read(src_fd,buf,99);
if(count <= 0){
perror("read");
return;
}
count = write(dst_fd,buf,count);
if(count <= 0){
perror("write");
return 0;
}
}
err = close(src_fd);
if(err != 0){
perror("close_error:src");
return 0;
}
err = close(dst_fd);
if(err != 0){
perror("close_error:dst");
return 0;
}
return 0;
}