Also found this. But you really should use google yourself :)
Use the ostream class (cout is an ostream) This should work for both a =
CONSOLE and a Windows application.=20
Advantages: Easy printing of simple text.=20
Disadvantages: Can only print to local printer.=20
Code:=20
filebuf fb( "prn:" ); // Filebuf object attached to "prn:"
cout =3D &fb; // fb associated with cout=20
cout << "testing"; // Text goes to PRN: not stdout
/M
----- Original Message -----=20
From: Lloyd Ashmore=20
To: dev...@li...=20
Sent: Wednesday, February 18, 2004 6:47 PM
Subject: [Dev-C++] Output to printer
When using this code below is there a different code other than "PRN" =
to send the code to the printer.
I have tried USB001 where a printer is attached. Using Windows XP.
#include <fstream.h>
int main()
{
char* s1 =3D "\nToday's winning number is ";
int n1 =3D 17982;
ofstream outfile;
outfile.open("PRN");
outfile << s1 << n1 << endl;
outfile << '\x0D';
return 0;
}
Thanks Lloyd
|