Solved

Network Printers

Posted on 1998-06-19
1
193 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

920 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

17 Experts available now in Live!

Get 1:1 Help Now