Sams Teach Yourself C in 21 Days

(singke) #1
Printing Your Listings 27

36: fprintf( stdprn, “%4d:\t%s”, line++, buffer );
37: }
38:
39: fprintf( stdprn, “\f” );
40: fclose(fp);
41: return 0;
42: }
43:
44: void do_heading( char *filename )
45: {
46: page++;
47:
48: if ( page > 1)
49: fprintf( stdprn, “\f” );
50:
51: fprintf( stdprn, “Page: %d, %s\n\n”, page, filename );
52: }

LISTINGT&R 1 continued

This listing uses a value that is available within many PC compilers, but not
necessarily in all other compilers. Although stdoutis an ANSI-defined value,
stdprnis not. You need to check your compiler for specifics on sending out-
put to the printer.
One option for getting around this is to change the stdprnstatements to
stdoutstatements. This causes the output to go to the screen. Using your
operating system’s redirection features (or by piping if you’re using UNIX or
Linux), you should be able to redirect the output from the screen to the
printer.

Note


On Day 14, “Working with the Screen, Printer, and Keyboard,” you will learn more
about how this program works.

04 448201x-T&R1 8/13/02 11:20 AM Page 27

Free download pdf