Does anybody have a tested function in C or C++ that sends text to the printer in a Windows Console Application? I would be very appreciative!

It would be nice, if I could specify the font. Yes, I can google!

The easiest solution is to first try opening one of the following streams:

ofstream pout("PRN");
ofstream pout("LPT1");
ofstream pout("PRN:");
ofstream pout("LPT1:");

If none of those work, and your compiler doesn't support an extension for talking to a printer, google over to MSDN and see what you can find. But don't use the MSDN search feature, it really bites.

If you don't mind using the old FILE structure, you can print by using:

FILE *fp;
fp = fopen(prn, w);
fprintf(prn, "%s", charstr);

i want to print the report on printer.

which function plz tell me

Lol? They just told above. And what report?
Elaborate if you want any kind of help, and please include why you think the two previous suggestions are useless :)

This article has been dead for over six months. Start a new discussion instead.