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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

print to printer

Status
Not open for further replies.

hughLg

Programmer
Feb 18, 2002
136
MY
I'm using Windows Me and Borland C++ Builder 5.5, I'm going to develop console application. How to write the function that print data to printer?

stdprn and some dos functions (e.g. bdos() and int86() is unavailable is not available in my builder...
 
You could try one of
Code:
FILE *fp = fopen( "LPT1:", "w" );
FILE *fp = fopen( "PRN:", "w" );
FILE *fp = fopen( "LPT1", "w" );
FILE *fp = fopen( "PRN", "w" );
It's been so long since I last did that, I can't remember what DOS device names look like.

If one doesn't work, check first to see if it created a file of that name containing your printed text, then try another name.
If you get no filename, and no output, then something else is amiss.

Remember to finish your output to the printer with
Code:
fprintf( fp, "\f" );  // page feed
This causes any data buffered by the printer to be committed to paper.

--
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top