Listing 6

/* Write to printer, file, or nowhere using stdprn */

         if (where_to_go == GO_TO_PRINTER)
             file_printer = stdprn;
          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, if it is not the real printer */
         if (where_to_go != GO_TO_PRINTER)
             fclose (file_printer);

         }