Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
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
?
280 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
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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…
Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.

578 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