[Error] 'stdprn' was not declared in this scope一直出现这个,好几个地方都是这问题。高手帮忙看看
/*print_it.c-Thisprogramprintsalistingwithlinenumbers!*/#include<stdlib.h>#include<st...
/*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;
int main( int argv, char *argc[] )
{
char buffer[256];
FILE*fp;
if(argv<2)
{
fprintf(stderr,"\nProper Usage is:");
fprintf(stderr,"n\nprint_it filename.ext\n");
return(1);
}
if ((fp=fopen(argc[1],"1"))==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);
return 0;
}
void do_heading(char*filename)
{
page++;
if (page>1)
fprintf( stdprn,"\f" );
fprintf( stdprn,"Page:%d,%s\n\n", page, filename );
} 展开
#include<stdlib.h>
#include<stdio.h>
void do_heading(char *filename);
int line=0,page=0;
int main( int argv, char *argc[] )
{
char buffer[256];
FILE*fp;
if(argv<2)
{
fprintf(stderr,"\nProper Usage is:");
fprintf(stderr,"n\nprint_it filename.ext\n");
return(1);
}
if ((fp=fopen(argc[1],"1"))==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);
return 0;
}
void do_heading(char*filename)
{
page++;
if (page>1)
fprintf( stdprn,"\f" );
fprintf( stdprn,"Page:%d,%s\n\n", page, filename );
} 展开
1个回答
2015-10-16
展开全部
stdprn值标准打印机,它在stdio.h中没有定义,如果希望通过打印机输出,可采取自定义stdprn的方法,比如:
FILE *stdprn;
stdprn = fopen("PRN","wb");
fprintf(stdprn,"Hello, printer! \r\n");
fclose(stdprn);
FILE *stdprn;
stdprn = fopen("PRN","wb");
fprintf(stdprn,"Hello, printer! \r\n");
fclose(stdprn);
追问
谢谢啊,刚才那个我把stdprn改成stdout成了,我刚开始看着书学的,下面这个我不知道怎么弄了
#include
int main(void)
{
printf("This is a program with a");
"do_it"("problem!");
return 0;
}
[Error] expression cannot be used as a function
追答
"do_it"( )没有定义,当然会报错。如果只有include,只要不是在它里面定义的函数,都不能使用,或者include进来,或者自定义。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询