Why getch() returns before press any key?
问题 int main(int argc, char *argv[], char *env[]) { printf(\"Press any key to exit.\\n\"); getch(); return 0; } According to the man page, getch should wait until any key is pressed ...but in fact it returns directly before press any key. (The value returned is -1 ). Why? Update I\'m on Linux. How can I implement Press any key to exit. , if not using getch() ? getchar() will only return after press Enter, it\'s not what I want. 回答1: On Linux, getch() is probably the curses function, which is