Linux下getch()使用的问题
#include <stdio.h>#include <curses.h>
int main(void)
{
char ch;
printf("Input a key:");
initscr();
ch = getch();
endwin();
printf("you put a %c \n",ch);
return 0;
}
linux下为什么第一个printf不会输出,程序运行之后,我输入一个按键(比如:K),然后输出you put a K。
Input a key:------>这一行没有输出啊? 你写的这个程序是顺序执行的,程序输出you put a K后,再一句就是return 0程序都退出了。怎么可能输出呢?
你需要的循环结构!
用while或for吧。
页:
[1]