unxgetch.c
来自「c语言库函数!里面包含了所以c语言中的系统函数的实现及其详细说明和代码!请大家及」· C语言 代码 · 共 44 行
C
44 行
/* +++Date last modified: 05-Jul-1997 */
/*
** UNXGETCH.C - Non-blocking console input function for Unix/Posix.
**
** public domain by Bob Stout using Steve Poole's term_option().
*/
#include "unxconio.h"
int getch()
{
int istat, key;
char buf[2];
if (0 > term_option(1))
return EOF;
if (0 > term_option(2))
return EOF;
istat = read(STDIN_FILENO,&buf,1);
if (istat < 0)
key = EOF;
else key = (int)buf[0];
term_option(0);
return key;
}
#ifdef TEST
#include <ctype.h>
main()
{
int key;
printf("Press any key to continue...");
fflush(stdout);
key = getch();
printf("\n\nYou pressed \"%c\"\n", toupper(key));
return 0;
}
#endif /* TEST */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?