I read these concepts from the book and I searched a lot on internet too but there is no good definition and explanation available. Everywhere it is just written that putch()
, putchar()
and fputchar()
work in the same way and are used to print character to console but I think there must be some different between them ?
This simple manual page certainly describes the differences, albeit tersely:
fputc()
writes the character c
, cast to an unsigned char
, to stream.putc()
is equivalent to fputc()
except that it may be implemented as a macro which evaluates stream more than once.putchar(c)
is equivalent to putc(c, stdout)
.From here:
int fputc(int c, FILE *stream);
int putc(int c, FILE *stream);
int putchar(int c);
The fputc() function writes the character c (converted to an ``unsigned char'') to the output stream pointed to by stream.
The putc() macro acts essentially identically to fputc(), but is a macro that expands in-line. It may evaluate stream more than once, so arguments given to putc() should not be expressions with potential side effects.
The putchar() function is identical to putc() with an output stream of stdout.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With