devxlogo

Send Output to Printer

Send Output to Printer

How do I send the output of my program to the standardprinter installed in Win95 or NT? Is it possible using the #include

To print to the standard printer usually means you have a printer connected to the PC's local parallel port. As a minimum there should be at least one port installed that is referred to by the operating system as lpt1.

In a network scenario, it is usually not cost effective to have one printer for each PC such that the printers are connected directly to the PC's parallel port. Therefore it is often the case that lpt1 is redirected to a printer that resides elsewhere on the network.

Regardless, to write data to lpt1 is the same as writing to a file. All you have to do is call fopen, passing lpt1 as the first parameter and "w" as the second, indicating that you intend to write to lpt1. fopen will return a valid FILE pointer if the file open is successful, else it will return NULL.

At this point you could write to lpt1, which will in effect print by using the fprintf function. However, you want to use the

devx-admin

Share the Post: