//使用C语言库函数实现文件复制
#include<stdio.h>
#include<stdlib.h>
#include<sys/types.h>
#define BUFFER_SIZE 1024
int main(int argc,char *argv[])
{
FILE *from_fd,*to_fd;
int read_bytes;
//Open source file
if ((from_fd=fopen(argv[1],"rt"))==NULL)
{
puts("open source file failed");
exit(1);
}
//Open destination file
if ((to_fd=fopen(argv[2],"wt+")==NULL)
{
puts("open destination file failed");
exit(1);
}
//copy code block
while ((read_bytes=fread(buffer,sizeof(char),BUFFER_SIZE,from_fd))>0)
fwrite(buffer,sizeof(char),read_bytes,to_fd);
fclose(from_fd);
fclose(to_fd);
}
//使用Linux系统调用实现文件复制
#include<stdio.h>
#include<stdlib.h>
#inclu