home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!gatech!rutgers!igor.rutgers.edu!remus.rutgers.edu!ficara
- From: ficara@remus.rutgers.edu (ken ficara)
- Newsgroups: comp.sys.mac.programmer
- Subject: fprintf to ImageWriter??? Help!
- Summary: Trying to write to printer w/ stdio functions
- Keywords: debugging macintosh imagewriter think c
- Message-ID: <Jan.2.12.45.21.1993.16716@remus.rutgers.edu>
- Date: 2 Jan 93 17:45:22 GMT
- Organization: Rutgers Univ., New Brunswick, N.J.
- Lines: 53
-
- In Scott Knaster's HOW TO WRITE MACINTOSH SOFTWARE, 2nd ed, page 118,
- a useful debugging technique is suggested: opening the printer port
- and using standard printing functions to send debugging info straight
- to the printer.
-
- He suggests the following in Pascal:
-
- var
- printer: Text;
- begin
- Reset (printer, '.bout');
- WriteLn (printer, 'Text text text...');
-
- I tried to translate this to C and came up with the following:
-
- #include <stdio.h>
-
- main ()
- {
- int i;
- FILE *printerPort;
-
- if (!(printerPort = fopen ( ".bout", "w")))
- printf ("%s","Cannot open printer.");
- else
- printf ("Opened printer.");
- if (ferror(printerPort))
- printf ("%s","Error on printer port stream.");
-
- /*
- for (i=1 ; i<=10 ; i++)
- printf (printerPort, "%s", "this is a test\n\r");
- */
-
- fclose (printerPort);
-
- }
-
-
- This program reports that the printer port has been opened and does
- not report an error on the stream. But it crashes with an address
- error,even if the printf statement is commented out.
-
- The Pascal version doesn't work either, but I'm not as familiar with Pascal.
-
- Does anyone know how to do this? It would be an incredibly useful
- technique but for the crashing. :)
-
- Thanks!
-
-
- Ken Ficara ficara@remus.rutgers.edu
- GEnie: K.FICARA / Compuserve: 71311,1461 / AOL: KENFICARA / Prodigy: (Ha!)
-