我怎样才能代替conio.h?与其他类似的功能不同,它不需要按Enter键。有来自标准库的类似物吗?
#include <conio.h>
#include <stdio.h>
int main(void)
{
char c;
unsigned i = 0;
while (1) {
c = getch();
printf("%d - %c", i, c);
++i;
}
return 0;
}发布于 2022-09-18 17:06:55
它不需要按回车
NCurses也不需要按Enter键。这是基于NCurses的代码,它允许:
#include <ncurses.h>
int main(void) {
char c;
unsigned i = 0;
initscr();
noecho();
while (1) {
c = getch();
printw("%d - %c", i, c);
++i;
}
endwin();
return 0;
}要编译,不要忘记包括"-lncurses",例如:
gcc main.c -lncurses -o main.exehttps://stackoverflow.com/questions/73178012
复制相似问题