Open
Description
Purpose is to write the time and overwrite it at the same line:
while(1) {
time_t seconds = time(NULL);
char buffer[32];
strftime(buffer, 32, "%I:%M:%S %p", localtime(&seconds));
printf("%s \r", buffer);
int i = 1000000;
while(i--); // keep busy (sleep gives programming issues and printf cannot flush)
ThisThread::sleep_for(5000);
}
But when the ThisThread::sleep_for(5000); is inserted, the printf will never be executed.
If you change \r to \n it works, but then you get a new line on each printf.