print to different ports(lpt1,lpt2,lpt3....)

Could not find a right place to ask this, so since I a need to do this in c++ , then I ask here....sorry.

I need to send output to different parallel ports for printing. stdprn is mapped to LPT1, how can I print in c++ to LPT2, LPT3, and so on...
migueAsked:
Who is Participating?
 
nietodConnect With a Mentor Commented:
Just open them like a file.

ofstream LPT2("LPT2");

LPT2 ,<< "This Is a Test" << endl;
0
 
chensuCommented:
What operating system?
0
 
migueAuthor Commented:
this solution is for a dos-protected program running on plain dos and any version of windows.
0
 
nietodCommented:
Then just open the printer port as a file.  You can use an output file stream as  I showed you above.  Or you can use the C file I/O functions (fopen(), fwrite(), fclose()) or you can even use the DOS service interrupts.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.