Okay so, I'm pretty new to C.
I've been trying to figure out what exactly is the difference between putch()
and putchar()
?
I tried googling my answers but all I got was the same copy-pasted-like message that said:
putchar()
: This function is used to print one character on the screen, and this may be any character from C character set (i.e it may be printable or non printable characters).
putch()
: Theputch()
function is used to display all alphanumeric characters through the standard output device like monitor. this function display single character at a time.
As English isn't my first language I'm kinda lost. Are there non printable characters in C? If so, what are they? And why can't putch
produce the same results?
I've tried googling the C character set and all of the alphanumeric characters there are, but as much as my testing went, there wasn't really anything that one function could print and the other couldn't.
Anyways, I'm kind of lost.
Could anyone help me out? thanks!
TLDR;
what can putchar()
do that putch()
can't? (or the opposite or something idk)
dunno, hoped there would be a visible difference between the two but can't seem to find it.
CodePudding user response:
putchar()
is a standard function, possibly implemented as a macro, defined in <stdio.h>
to output a single byte to the standard output stream.
putch()
is a non standard function available on some legacy systems, originally implemented on MS/DOS as a way to output characters to the screen directly, without the buffering implemented by standard streams. This function is mostly obsolete, don't use it.
Output via stdout
to a terminal is line buffered by default on most systems, so as long as your output ends with a newline, it will appear on the screen without further delay. If you need output to be flushed in the absence of a newline, use fflush(stdout)
to force the stream buffered contents to be written to the terminal.
CodePudding user response:
putch replaces the newline character (\ n)
putchar is a function in the C programming language that writes a single character to the standard output