Solved

printing

Posted on 2003-11-04
12
239 Views
Last Modified: 2010-04-15
if i am using fputchar
how do i send it to the printer?
0
Comment
Question by:shorty225
  • 3
  • 2
  • 2
  • +2
12 Comments
 

Author Comment

by:shorty225
Comment Utility
if i am using putchar
how do i get it to print to the printer
0
 
LVL 10

Expert Comment

by:Sys_Prog
Comment Utility
Here's the help for putchar


Function: int putchar (int c)

The putchar function is equivalent to putc with stdout as the value of the stream argument.


Here's the help for putc

Function: int putc (int c, FILE *stream)

This is just like fputc, except that most systems implement it as a macro, making it faster.  One consequence is that it may evaluate the stream argument more than once, which is an exception to the general rule for macros.  putc is usually the best function to use for writing a single character.

Thus, I think u should use putc for your task
0
 

Author Comment

by:shorty225
Comment Utility
my chararters are coming in from a file
its like 20 lines per page
is there anyway fputchar will print this to the printer
0
 
LVL 45

Accepted Solution

by:
sunnycoder earned 250 total points
Comment Utility
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 5

Assisted Solution

by:g0rath
g0rath earned 250 total points
Comment Utility
under linux, you can print to the /dev/lp0 device
under windows, you can go to lpt1 etc...

under linux you could pipe  your data to lpr/lpd and send your output to a remote printer.

The first do will all use the buffered file I/O family of functions

fprintf
fputs
fputchar
fputc

The other would require pipes and a little more effort
0
 
LVL 9

Expert Comment

by:ankuratvb
Comment Utility
sure it can.

putchar(c,PRN);

where c is the character to print.
PRN is defined as the printer port
0
 
LVL 9

Expert Comment

by:ankuratvb
Comment Utility
FILE *prn;
char c;
prn=fopen("PRN","wb");
putchar(c,prn);
fclose(prn);

Or on some systems:

prn=fopen("LPT1","wb");

Another one:

prn=fopen(stdprn,"wb");

On my system,all 3 work.

I guess i am too late on this one as well.
0
 
LVL 9

Expert Comment

by:ankuratvb
Comment Utility
sorry,replace putchar with fputc.
0
 
LVL 5

Expert Comment

by:g0rath
Comment Utility
yeah, guess the original guy wasn't really that interested...we've all answered these with good answers, but I guess without the original guys response it would be better to split the points since they are all "accurate" but who knows which way the original guy would have wanted since there is more then one way do this operation depending on OS, needs, etc...
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
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 and use switch statements in the C programming language.

743 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now