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

How to print on printer using c language for Unix?

Status
Not open for further replies.

surnj1

Technical User
Dec 27, 2001
46
US
Hi,

I am new to Unix Programming. I was printing in DOS using
following c syntex:

fprintf(stdprn,"Print this line to Printer");

The Standrad Printer device made this possible. What is Unix equvalent to DOS's "stdprn"?

I am using GNU's gcc compiler on SCO Open Server 5.0.x

Thanks for your help.

Bob
 
Don't think there is an equivalent - I may be corrected !
So - open a file for write only
FILE *fp;
fp=fopen(file_name,"w");

and then
fprintf(fp,"Print this line to Printer");
and then lp -dprinter_name file_name outside of the C prog.
HTH Dickie Bird (:)-)))
 
i will try the same way, using popen()
man is your frend.
 
#include <stdio.h>

main(int argc, char **argv)
{
FILE *fp;

fp = fopen(&quot;/dev/lp&quot;);

fprintf(fp, &quot;this will go directly to the printer\n&quot;);

fclose(fp);
}

# type lpstat -t to find which device the printer is on and
# change /dev/lp appropriatly
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top