|
-
Sep 4th, 2003, 05:00 AM
#1
Thread Starter
Fanatic Member
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
sql_lall 
-
Sep 4th, 2003, 08:08 AM
#2
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;
}
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Sep 4th, 2003, 09:02 AM
#3
Monday Morning Lunatic
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.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Sep 4th, 2003, 03:51 PM
#4
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.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Sep 5th, 2003, 03:51 AM
#5
Thread Starter
Fanatic Member
:D
Thanks, I'll try them and get back if there are any problems
sql_lall 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|