• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 218
  • Last Modified:

Network Printers

Ok, I was asked this question and I didn't know the answer.  How do you print to a network printer using ostream?

This code works:
int main()
        ofstream printer ("prn");
        printer << "This line is on the printer\n";
        return 0;

works OK if the printer is attached to LPT1, but does not print on the
network printer

Thanks for your help
1 Solution
You should be able to specify the network path to the ofstream, like

    ofstream printer ("\\\\wchs\\hp4000_wchs_g129");

Note that each "\" is expressed as two "\"s in the string.  That should work fine.
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.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now