-
Printer as outputstream
Hello!
Just wondering if possible to use the printer as an outputstream (ostream) similar to files and cout.
So you can do stuff like:
Printer<<"Printing text, and the number "<<5<<endl;
(Then i guess something like Printer.close())
I have converted from VBasic ages ago, and was used to treating the printer as a file or textbox.
Also, if you can't do this, how do you access the printer?
Thanks
-
If memory serves, you can do something like this...
Code:
#include <fstream>
using namespace std;
int main()
{
ofstream OUT;
OUT.open("LPT1");
OUT << "Printing Text" << endl;
OUT.close();
return 0;
}
-
That works fine for most Windows variants (dead easy to map LPT1: to a network drive, too).
Under Unix, you can probably get away with writing to a file then just throwing it through lpr.
-
Or opening the printer's device file from /dev.
Might be parn or parportn (with n being the LPT number starting with 0, par0, par1 etc.).
lpn also sounds promising.
-
:D
Thanks, I'll try them and get back if there are any problems