Note that getch () is read from the console (non-standard function)
Getch () required header file is <conio.h>.
and GetChar () is from stdin, generally refers to the keyboard
The ENTER key on the Windows platform generates two escape characters \ r \ n,
\ r: Back to the beginning of the place.
\ n: Go to the beginning of the next line
Therefore, Getch () will return his ASCII code 13 when it reads \ r. (the back is ignored)
The odd question is why GetChar () will return 10?
Didn't you say that the first character is returned?
This is really confusing. In fact, the reason for this result is that
GetChar () converts the input \ r \ n to \ n,
So the return is \ n ASCII code 10. Why is that?
Because the previous getchar () is a C standard library function,
In the UNIX system, the ENTER key only generates \ n. By the way,
The ENTER key in Mac OS will generate \ R and will also be replaced by \ n.
In this way, GetChar () will get the same results, regardless of the platform,
So say GetChar () standard library functions.
Http://www.cnblogs.com/candyming/archive/2011/11/25/2262877.html
The difference between Getch and GetChar under Windows and UNIX