【发布时间】:2020-05-17 15:24:00
【问题描述】:
我想在 C 中创建一个代码,它运行一个循环并在我点击“1”但不按 ENTER 时中断循环。
我使用 GCC 编译器。
示例代码:
While-loop 必须始终不间断地运行,直到我按下 '1' 但没有按 ENTER ...(bin/stty raw)
int c=0;
int leave=0;
system ("/bin/stty raw");
while ((leave=getchar()) != '1'){
c++;
printf("\n- - while loop nr. %d\n",c);
sleep(1);
}
system ("/bin/stty cooked");
printf("\n-- end of loop...\n");*
...
【问题讨论】:
-
Bitte, sprechen si English.
-
嗨 KingOrgie,请用英语替换您的语言文本。
-
你需要为此使用 ncurses
-
@P__J_ 很好,谢谢你的第一个......你能告诉我如何实现它吗?
-
不——网上的例子太多了
标签: c while-loop getchar