C++ keypress: getch, cin.get?

前端 未结 6 1132
逝去的感伤
逝去的感伤 2020-12-15 16:48

I have a Win32 program that runs on a loop. I would like to be able to pause that program while awaiting a keypress. It doesn\'t matter whether I use \'any key\' or a specif

6条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-15 17:07

    You should use neither.

    You should use

    #include 
    ...
    int main()
    {
       ... 
       std::cin.ignore(); //why read something if you need to ignore it? :)
    }'
    

    Here's the documentation

提交回复
热议问题