dev-c++不显示运行结果
这是书上代码,我是菜鸟,加了一行system("PAUSE");还是没有,求高手/*print_it.c-thisprogramprintsalistingwithlin...
这是书上代码,我是菜鸟,加了一行system("PAUSE");还是没有,求高手
/* print_it.c-this program prints a listing with line numbers!*/
#include<stdlib.h>
#include<stdio.h>
void do_heading(char *filename);
int line=0,page=0;
FILE *stdprn;
int main(int argv,char *argc[])
{
char buffer[256];
FILE *fp;
if(argv<2)
{
fprintf(stderr,"\nProper Usage is: ");
fprintf(stderr,"\nprint_it filename.ext\n");
return(1);
}
if ((fp=fopen(argc[1],"r"))==NULL)
{
fprintf(stderr,"error opening file, %s!",argc[1]);
return(1);
}
page=0;
line=1;
do_heading(argc[1]);
while(fgets(buffer,256,fp)!=NULL)
{
if(line%55==0)
do_heading(argc[1]);
fprintf(stdprn,"%4d:\t%s",line++,buffer);
}
fprintf(stdprn,"\f");
fclose(fp);
system("PAUSE");
return(0);
}
void do_heading(char*filename)
{
page++;
if(page>1)
fprintf(stdprn,"\f");
fprintf(stdprn,"page:%d,%s\n\n",page,filename);
} 展开
/* print_it.c-this program prints a listing with line numbers!*/
#include<stdlib.h>
#include<stdio.h>
void do_heading(char *filename);
int line=0,page=0;
FILE *stdprn;
int main(int argv,char *argc[])
{
char buffer[256];
FILE *fp;
if(argv<2)
{
fprintf(stderr,"\nProper Usage is: ");
fprintf(stderr,"\nprint_it filename.ext\n");
return(1);
}
if ((fp=fopen(argc[1],"r"))==NULL)
{
fprintf(stderr,"error opening file, %s!",argc[1]);
return(1);
}
page=0;
line=1;
do_heading(argc[1]);
while(fgets(buffer,256,fp)!=NULL)
{
if(line%55==0)
do_heading(argc[1]);
fprintf(stdprn,"%4d:\t%s",line++,buffer);
}
fprintf(stdprn,"\f");
fclose(fp);
system("PAUSE");
return(0);
}
void do_heading(char*filename)
{
page++;
if(page>1)
fprintf(stdprn,"\f");
fprintf(stdprn,"page:%d,%s\n\n",page,filename);
} 展开
2个回答
展开全部
把system("PAUSE");改成system("pause");
实在不行那就这样吧,把system("PAUSE");换成scanf("%d", &line);产生中断后可以看到打印,关的时候输入一个字母或数字再回车就行了
实在不行那就这样吧,把system("PAUSE");换成scanf("%d", &line);产生中断后可以看到打印,关的时候输入一个字母或数字再回车就行了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询