1,第1版 copy
先写个轮廓
selfcp.c :
#include <stdio.h>int main() {FILE *source, *destination;char ch;source = fopen("H222.txt", "r");if (source == NULL) {printf("Error opening source file!\n");return 1;}destination = fopen("H333.txt", "w");if (destination == NULL) {printf("Error opening destination file!\n");return 1;}while ((ch = fgetc(source)) != EOF) {fputc(ch, destination);}printf("File copied successfully!\n");fclose(source);fclose(destination);return 0;
}
拷贝文本文件:
测试拷贝elf 可执行文件,拷贝结束后,再运行拷贝的结果,会出现 segmentation fault
待查。。。