0

私のプログラムはそのように見えます

/* 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], “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] );

Type & Run 1
nting Your Listings 27
 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 );
 }

Win 8 + VS 2012を使用します。これをコンパイルするには、Developer Command Promptを開き、次のように入力します。

cl print_it.c

この画面が表示されました(一連のエラーと警告)

ここに画像の説明を入力してください

私は何が欠けていますか?

4

2 に答える 2

4
于 2012-08-21T09:26:38.233 に答える
1

As @cnicutar mentioned, fix the broken double quotes first and remove the garbage.

However, you won't get this program compile with Visual C++ due to the fact there is no stdprn stream available on Windows

See How can I make the printer work in C in MS VC++ Express edition? for details on how to work around it.

于 2012-08-21T09:37:39.613 に答える