0

i'm trying to make a stopwatch pause by making the thread sleep until a key is pressed, but _kbhit() will not return an integer?

the error is displayed in the image below: enter image description here

i tried to a quick search but wasn't able to find a solution to my problem

chapel1337
  • 27
  • 5
  • neither `conio.h` nor `_kbhit` are in the C++ standard. Just avoid them – phuclv Dec 01 '22 at 02:04
  • @phuclv what's an alternative for getting unbuffered key input then? – chapel1337 Dec 01 '22 at 02:05
  • 1
    [`std::this_thread::sleep_until`](https://en.cppreference.com/w/cpp/thread/sleep_until) does not take an `int` as its argument. It takes an `std::chrono::time_point`. – heap underrun Dec 01 '22 at 02:06
  • @heapunderrun the error states that the required argument type is an integer, and the ms docs say that it returns a non-zero value (https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/kbhit?view=msvc-170) – chapel1337 Dec 01 '22 at 02:07
  • 1
    No, it states that the argument you have provided is `int`, but there is no overload taking such type (`int`). – heap underrun Dec 01 '22 at 02:09
  • I can see how you read the message that way. It's probably only years of experience that have us reading the message the "right" way. Not very intuitive. – user4581301 Dec 01 '22 at 02:38

0 Answers0