Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem Printing...

Status
Not open for further replies.

martindavey

Programmer
Jan 2, 2000
122
GB
Could you maybe tell me what I am doing wrong here??

I am trying to print direct to the printer in W98 using MS Visual C++ am getting no errors opening the stream (My printer is known as lpt1 on my system) but no printer activity is witnessed.

I know in C, W98 makes it next to impossible to print directly but am learning C++ and my course work says it should work as below but it does not.

Any suggestions would be great!

#include <iostream.h>
#include <fstream.h>
#include <stdlib.h>

int main()
{
// tried ofstream no change
fstream Print;

// tried &quot;LPT1&quot; no change
Print.open(&quot;lpt1&quot;,ios::eek:ut);

// function returns 1 hence stream opened ok
if(!Print.is_open())
{
cout<<&quot;Error Opening File, Program Aborted&quot;;
exit 1;
}

// WHY WHY WHY BOOHOOOHOO :)
Print<<&quot;WHY DOESNT THIS PRINT!\n&quot;;

return 0;
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top