#include <stdio.h>
#include <stdlib.h>
int main(){
char name[50]="F:\\text1.txt";//与char name[50]="F:/text1.txt"等价
FILE * fp= fopen(name,"r");
if(fp==NULL){
printf("文件打开失败,程序退出");
exit(-1);
}
FILE * fp1= fopen("F:\\text2.txt","w");
if(fp1==NULL){
printf("文件打开失败");
exit(-1);
}
char ch;
while((ch= fgetc(fp))!=EOF){
fputc(ch,fp1);
}
fclose(fp);
fclose(fp1);
return 0;
}
打开关闭及读写文件
最新推荐文章于 2024-07-24 14:05:37 发布