GetChar () and Getch () are all functions used to capture input characters from the keyboard, what is the difference between them?
The GetChar () function takes the character as follows: When executed to the GetChar () function, the user enters the character from the keyboard and caches it in buffer in memory, and GetChar () actually assigned the buffer's word to the variable only when the ENTER key is pressed. At the same time, the ENTER key is also stored in buffer, and another getchar () function must be used to get the enter value in buffer. This is the biggest problem with the GetChar () function. Of course, the input cache also has a benefit-when the user enters the wrong character, the input character can be modified by BACKSPACE.
Getch () solves the problem of the GetChar function enter key, the Getch () function, when executed, directly to the keyboard input Word assigned value to the variable, and omitted the steps of the cache.
Thus, the Getch () function can achieve a higher efficiency than the getchar, and the disadvantage is that the value of the wrong input cannot be corrected.
The difference between C language-getchar () and Getch ()