输入输出 - getchar

原型:extern int getchar(void);

用法:#include <ctype.h>

功能:读键

说明:从键盘上读取一个键,并返回该键的键值

getch是到getchar的宏定义 举例:


      // getchar.c
      
      #include <stdio.h>

      main()
      {
        int c;
        
        clrscr();
        printf("Press key...");
        while((c=getchar())!='Q')
        {
          clrscr();
          printf("key: %c\nvalue: %x",c,c);
        }
      }
      
  
相关函数:getkey,kbhit