/* list_it.c__This program displays a listing with line numbers! */
#include <stdio.h>
#include <stdlib.h>
#define BUFF_SIZE 256
void display_usage(void);
int line;
int main( int argc, char *argv[] )
{
char buffer[BUFF_SIZE];
FILE *fp;
if( argc < 2 )
{
display_usage();
return 1;
}
if (( fp = fopen( argv[1], "r" )) == NULL )
{
fprintf( stderr, "Error opening file, %s!", argv[1] );
return(1);
}
line = (1);
while( fgets( buffer, BUFF_SIZE, fp ) != NULL )
fprintf( stdout, "%4d:\t%s", line++, buffer );
fclose(fp);
return 0;
}
void display_usage(void)
{
fprintf(stderr, "\nProper Usage is: " );
fprintf(stderr, "\n\nlist_it filename.ext\n" );
}题目说可以将显示整个程序的代码,包括行数,但是,我在VC上运行,没有显示全部的代码!只显示了下图的结果!求大神指点!
- 1 回答
- 0 关注
- 1408 浏览
添加回答
举报
0/150
提交
取消