第1个回答 2023-03-11
以下是简单的C语言代码示例:
#include <stdio.h>
#define BUFFER_SIZE 1024
int main(){
FILE *sourceFile, *targetFile;
char buffer[BUFFER_SIZE];
sourceFile = fopen("D:\\pro.txt", "r");
targetFile = fopen("D:\\pc.txt", "w");
while (fgets(buffer, BUFFER_SIZE, sourceFile)) {
fputs(buffer, targetFile);
}
printf("文件复制成功,已保存在D:\\pc.txt");
fclose(sourceFile);
fclose(targetFile);
return 0;
}
_