This program listing from the book "C By Example" (QUE pub. 1993) page 538, "Writing to a Printer" does not work for me.
I'm using WIN98 and Borland TURBO C++ 3.1 and
Borland C++4.0. The program is compiled as print.c using the IDE
option. The Printer is an HP DeskJet 832C.
The code suggested by 'moi' will not compile while using Borland Turbo C++ 3.1, but does compile when using Borland C++ 4.0.
But the output would not go to the printer.....
The suggestion from Salem confuses me (I'm new to programming).
Do not know the correct format to use at the Command line (is this the DOS C prompt?). Or should the "print file.txt" be included in the C program?
Program listing from the book:
/*Writing to a printer */
#include <stdio.h>
FILE *prnt;
main()
{
prnt = fopen("LPT1", "w");
fprintf(prnt, "This is a test.\n");
fclose(prnt);
return(0);
}
The output always goes to the screen, not to the printer.
No problem printing the code.
Thanks in advance for any suggestions.



LinkBack URL
About LinkBacks



my code isnt exactly the same as yours, but the only difference is a little error checking and platform-specfic stuff. what OS are you under? dos box in win95? also newer printers dont expect raw unformatted data from the parallel port i dont think; i have an epson stylus color original, and i know when it came out the raw text output from lpt to printer was a dying thing (it has the economy/condensed, font, load eject buttons on it, nessecary for this sort of thing).