0

I have a while loop that displays the the current time in two different formats, then clears the screen, adds a second and then redisplays the time again.

I would like for this loop to continue until the user hits a key, and then it goes into a separate loop that asks for user input. If I use cin it pauses the entire loop waiting for the user input. Is there a way to avoid pausing the loop to get user input?

mkrieger1
  • 19,194
  • 5
  • 54
  • 65
Bmore
  • 9
  • 5
  • 1
    Does this answer your question? [Capture characters from standard input without waiting for enter to be pressed](https://stackoverflow.com/questions/421860/capture-characters-from-standard-input-without-waiting-for-enter-to-be-pressed) (referred to from https://stackoverflow.com/questions/61019697/can-you-simultaneously-get-user-input-while-also-running-a-function-in-c-for-a) – mkrieger1 Jul 18 '21 at 20:45

1 Answers1

-1

spawn 2 threads ... Keep the loop running in first thread. Make the second thread wait for user input. Once the second thread returns exit first thread and continue with second loop on second thread ..

Test
  • 564
  • 3
  • 12