what is the difference between
getc(),getch(),getche().... similarly putc(),putch(),putche().....
what is the difference between
getc(),getch(),getche().... similarly putc(),putch(),putche().....
getc and putc are standard, getch/putch and friends are not. But assuming you use a compiler where getch and friends are supported, the difference is usually as follows:
- getc/putc - Works through the standard C stream framework and are not limited to the keyboard and console.
- getch/putch - Works directly with the keyboard buffer/console, respectively.
Further, getch differs from getc in behavior because the C stream framework is typically line buffered (this comes from the underlying shell) and input will not be sent to the program until a newline is detected. Thus getch and getche are ways to read a single character immediately without requiring the user to press the enter key.
Finally, getch and getche differ in that getch reads a character without echoing it to the screen while getche does echo the character. getc follows the rules of the underlying shell, which usually echoes the characters being typed.
My best code is written with the delete key.