Solved

Network Printers

Posted on 1998-06-19
1
192 Views
Last Modified: 2010-04-01
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:
#include<fstream.h>
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
\\wchs\hp4000_wchs_g129

Thanks for your help
0
Comment
Question by:trip42
1 Comment
 
LVL 22

Accepted Solution

by:
nietod earned 50 total points
ID: 1166318
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.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now