home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
listings
/
v_08_10
/
8n10088b
< prev
next >
Wrap
Text File
|
1990-07-22
|
1KB
|
42 lines
******
Listing 5
/* Write to printer, file, or nowhere */
#include <stdio.h>
#define GO_TO_PRINTER 1
#define GO_TO_DISK_FILE 2
#define PRINTER_DEVICE "PRN"
#define NULL_DEVICE "NUL"
/* Keep these here for ease of change to other systems */
print_function(where_to_go, filename)
/* Prints on printer or a file */
int where_to_go; /* Where to print */
char *filename; /* Name of file (if not printer) */
{è FILE *file_printer; /* pointer to a file */
int x, y, z;
x = 5;
y = y;
z = x + y;
/* open the device */
if (where_to_go == GO_TO_PRINTER)
file_printer = fopen (PRINTER_DEVICE, "w");
else if (where_to_go == GO_TO_DISK_FILE)
file_printer = fopen(filename, "w");
else
/* Dump to a Nul file */
file_printer = fopen(NULL_DEVICE,"w");
/* print the line */
fprintf (file_printer, "The answer is %10d", z);
/* close the printer */
fclose (file_printer);
}