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.

Narue,

thanks a lot! I will test drive your suggestion!

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

commented: Don't bump old threads -1

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 :)

can anyone give example of this printer statement??

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.