C语言中getch和getche的用法?最好有例子

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/02 16:53:15
C语言中getch和getche的用法?最好有例子

C语言中getch和getche的用法?最好有例子
C语言中getch和getche的用法?最好有例子

C语言中getch和getche的用法?最好有例子
#include
#include //linux 下
#include //window 平台
int main(void)
{
char ch;
initscr();//linux 下
printf("Input a character:");
ch = getch();
printf("\nYou input a '%c'\n", ch);
endwin();//linux 下
return 0;
}
#include
#include
int main(void)
{
char ch;
printf("Input a character:");
ch = getche();
printf("\nYou input a '%c'\n", ch);
return 0;
}
getche功 能: 输入后立即从控制台取字符,不以回车为结束(带回显)
getchg功 能: 在window平台下从控制台无回显地取一个字符,在linux下是有回显的.