#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
int main(int argc,char *argv[]) {
int srcfd = open("English.txt", O_RDONLY);
if (srcfd == -1) {
perror("English.txt文件没有正确打开!出错原因");
}
int destfd = open("copyFile.txt", O_WRONLY | O_CREAT, 0644);
if (srcfd == -1) {
perror("copyFile.txt文件没有正确打开!出错原因");
}
char buf[1024] = {0};
int len = 0;
while ((len = read(srcfd, buf, 1024)) > 0) {
write(destfd, buf, len);
}
close(srcfd);
close(destfd);
return 0;
}