#include <stdio.h>
#include<string.h>
#include<stdlib.h>
int main( )
{
int m,k=1,n;
char line1[256],line[256];//将文件中的数据读入到字符数组中
FILE *fpin = fopen("sourcefile.c","r");
if(fpin==NULL)
{
printf("source code read error!\n");
exit(1);
}
FILE *fpout = fopen("targetfile.c","w+");
if(fpout==NULL)
{
printf("source code write error!\n");
exit(1);
}
printf("请输入m和n:");
scanf("%d %d", &m, &n);
int n1=0;
fgets(line1,255,fpin);
do
{
n1++;
if(n1>=m&&n1<m+k)
fputs("//",fpout);
fputs(line1, fpout);
fgets(line1,255,fpin);
}
while(!feof(fpin));
fseek(fpout,0,SEEK_SET);
fgets(line,255,fpout);
do
{
printf("%d\t%s", k, line);
k++;
fgets(line,255,fpout);
}
while (!feof(fpout));
fclose(fpout);
fclose(fpin);
return 0;
}
C语言添加注释
最新推荐文章于 2024-02-22 22:27:31 发布