?
Solved

How to print to a printer?Want to print out regular text.I am on a linux os

Posted on 2003-02-24
7
Medium Priority
?
275 Views
Last Modified: 2010-04-15
I am on a linux os and trying to figure out how one can print out regular text to my printer.

I thought I could do something like this but found out I can't

  FILE *fp;
  fp=fopen("/dev/usb/lp0", "w");
  fprintf(fp,"hello");
  fclose(fp);


Thanks for your time and help.
0
Comment
Question by:DWA
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 1

Expert Comment

by:umangjoshi
ID: 8008278
I havn't experience of the linux plateform. But this may help you.

if i want to print something on screen, i use
printf("%d",i);

if i want to print on printer, i use
fprintf(STDPRN,"%d",i);

so please findout something similar...
0
 

Author Comment

by:DWA
ID: 8008369
Yeah I have found some stuff on a google search that suggested what you said but no luck.So far I have not found a good answer with a google search

Thanks for your time and reply
0
 

Author Comment

by:DWA
ID: 8008381
Let me try a search on stdprn
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:DWA
ID: 8008566
I still have not found nothing that is worth a darn.
0
 
LVL 2

Expert Comment

by:corduroy9
ID: 8011773

Here are a couple solutions...

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/devcons_562c.asp

...but they look Microsoft Visual C++ or Windows-dependent.  
0
 
LVL 1

Accepted Solution

by:
darlingm earned 80 total points
ID: 8016369
DWA,
Use popen and pclose rather tha fopen and fclose (Process I/O, rather than file I/O).
Assuming that lp is setup and prints :
   FILE *fp;
   fp=popen("lp", "w");
   fprintf(fp,"hello");
   pclose(fp);
You are simply opening another process and writing to it, sort of treating it like it were a file.  In the popen statement, your command (in this case, lp) can have command line arguments if need be.
0
 

Author Comment

by:DWA
ID: 8023032
Thanks to you all
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.
Suggested Courses

762 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