uTools-Manuals/docs/c/getchar.html
2019-04-08 23:22:26 +08:00

34 lines
654 B
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<h1>输入输出 - getchar</h1>
<p>原型extern int getchar(void);</p>
<p>用法:#include &lt;ctype.h></p>
<p>功能:读键</p>
<p>说明:从键盘上读取一个键,并返回该键的键值</p>
getch是到getchar的宏定义
举例:<pre>
// getchar.c
#include &lt;stdio.h>
main()
{
int c;
clrscr();
printf("Press key...");
while((c=getchar())!='Q')
{
clrscr();
printf("key: %c\nvalue: %x",c,c);
}
}
</pre>相关函数:<font color=gray>getkey</font>,<a href="kbhit.html">kbhit</a>