i wanted to make a simple program to keep updating the time until a key is pressed. for example:
Code:while(/*check for key press*/) { cout << time; }
i wanted to make a simple program to keep updating the time until a key is pressed. for example:
Code:while(/*check for key press*/) { cout << time; }
It may be more effective to loop every second rather than allow the loop to spin at the CPU's speed. Instead of waiting for a key press you could end the process by sending an interrupt like control+c. In Linux you can use signal masks and change behavior of signals.. you can even catch a signal and make it stop the loop and print the final time, etc.
Allow it to infinitely loop and set up a signal handler or another event handler to interrupt the loop and end it.