C语言编写程序输出源程序,在打印时每行均加上行号
1个回答
展开全部
#include<stdio.h>
#define N 1000
int main(void)
{
FILE *in, *out;
int i;
in = fopen("源.c", "rb");
char a[N];
fread(a, sizeof(char), N, in);
for (i = 0; i < N; i++)
{
if (a[i] == '/'&&a[i + 1] == '/'&&a[i + 2] == 's'&&a[i + 3] == 't'&&a[i + 4] == 'o'&&a[i + 5] == 'p'&&a[i + 6] == '0'&&a[i + 7] == '0'&&a[i + 8] == '1')
{
(a[i + 9] = '\0');
break;
}
}
printf("%s\n",a);
out = fopen("程序.txt", "wb");
fwrite(a, sizeof(char), N, out);
return 0;
}//stop001
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询