Getch ()
The header file: conio.h
function Purpose: Read a character from the console
Function prototype: int getch (void)
Return value: The character read
For example:
char ch; or int ch;
Getch (); or ch=getch ();
Use Getch (), wait for you to press any key, then continue to execute the following statement;
With Ch=getch (), wait for you to press any key, assign the ASCII code corresponding to the key character to CH, and then execute the following statement.
Easy to mistake Point:
1. The header file is conio.h. Rather than stdio.h.
2. Call INITSCR () before use, and call Endwin () at the end. Otherwise, this function will appear without entering characters.
will also return the case.
3. On different platforms, enter a return, Getch () will return a different value, and GetChar () uniform return 10 (that is \ n)
1 The Windows platform under the ENTER key produces two escape characters \ r \ n, so Getch returns (\ r).
2 the Enter key in Unix and Linux only produces \ n, so getch returns ten (\ n).
3 the ENTER key in MAC OS will generate \ r, so Getch returns (\ r).
Getch () is not a function in standard C and does not exist in C language. So in the use of the time to pay attention to the portability of the program. Domestic C language Novice often use getch (), to suspend the program and do not know the source of this function, it is recommended to use GetChar (), (if circumstances allow) to replace this feature or to replace a compiler.
View a full set of articles: Http://www.bianceng.cn/Programming/C/201212/34807.htm