C/C++ 언어 키보드 입력 kbhit()


1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <stdio.h>
#include <conio.h>
 
int main() {
  char ch1;
  int num=0;
 
  do {
    num = num + 1;
    printf("num : %d \n",num);
  } while (!_kbhit());
 
  return 0;
}
cs


_kbhit(void) 함수는 키보드의 입력 버퍼에 값이 있는지를 확인하는 함수입니다.


<conio.h> 헤더파일에 _CRTIMP int __cdecl _kbhit(void); 정의 되어 있습니다.

int형을 반환하며 1 혹은 0의 값이 (true or false) 리턴됩니다.





+ Recent posts