ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • C++ Keyboard Input
    C++ 2019. 4. 30. 12:11
    #include <iostream>
    #include <conio.h>
    using namespace std;
    
    int main()
    {
    	while (true) 
    		if (_kbhit)
    			cout << "Pressed Key :: " << (char)_getch() << endl;
    }

    _kbhit 키보드 입력 값이 있을 때 1 그 외 0

     

    _getch() 키보드의 입력 값 리턴 (char) 캐스팅을 사용하면 어떤 키를 눌렀는지 알 수 있다.

     

    댓글

Designed by Tistory.