Getch ():
Header file: conio. h
Function purpose: Read a character from the console, but it is not displayed on the screen.
Function prototype: int getch (void)
Returned value: read characters
For example:
Char ch; or Int ch;
Getch (); or CH = getch ();
Use getch (); wait for you to press any key, and then continue to execute the following statement;
Use CH = getch (); after you press any key, assign the ASCII code corresponding to the key character to CH, and then execute the following statement.
Easy to troubleshoot:
1. the header file is conio. h. Instead of stdio. h.
2. Call initscr () before use, and call endwin () at the end (). Otherwise, the function does not contain any characters.
The returned results.
3. on different platforms, enter the carriage return. getch () returns different values, while getchar () returns 10 (\ n) in a unified manner)
1) on Windows, the Enter key generates two escape characters \ r \ n. Therefore, getch returns 13 (\ r ).
2) in UNIX and Linux systems, the Enter key only produces \ n, so getch returns 10 (\ n ).
3) The enter key in Mac OS generates \ r, so getch returns 13 (\ r ).
Getch (); is not a function in Standard C and does not exist in C. Therefore, pay attentionProgramPortability. Chinese C language beginners often use getch (); to pause the program and do not know the function source. We recommend that you use getchar (); (if possible) to replace this function or change a compiler.