新维加斯丝袜:c语言文件题目

来源:百度文库 编辑:高考问答 时间:2024/04/28 07:51:21
编写程序给文本文件(例如.c文件)加上行号后存储到另外一个文本文件中.

#include<stdio.h>
main()
{
FILE *fr,*fw;
int ct=0;
char filer[100],filew[100];
char buffer[500];
printf("Input the file name to be open:\n");
scanf("%s",filer);
fr=fopen(filer,"r");
if(fr){
printf("Input the file name to be saved:\n");
scanf("%s",filew);
fw=fopen(filew,"w");
while(fgets(buffer,500,fr))
{ct++;
fprintf(fw,"%d %s",ct,buffer);
}
printf("file saved successfully!\n");
}
else printf("file not found!\n");
getch();
}

什么叫加上引号。。。说清楚,帮你搞