(In C prog.) What is the difference between scanf, getche and getchar?
Scanf is a standard C function, while getch and getchar are not. Scanf will read a stream and can even take formatted input, but getch and getchar will only take a single character. getchar() will read in a single character and wait for the user to hit the enter key before reading. getch() will immediately return the first character read or on any keyboard input.
@ArrowsAndDaggers getchar() is actually part of the C standard library. But you're right on all the other points.
getch() and getche() are both from the <conio.h> include file, part of some old MS-DOS C compilers. getch() takes a single character keypress from the user, without echoing the character on the screen, whereas getche() echoes the character on the screen.
Join our real-time social learning platform and learn together with your friends!