- #1
blue_tiger30
- 29
- 0
I did the following program
it gives my the following
so how can I make it only appear in one line that updated automatically ?
Code:
#include<stdio.h>
#include <stdlib.h>
#include <time.h>
int main (void) {
int sec,min,h;
printf("please enter the the time in the following format hh:mm:ss :");
scanf("%d:%d:%d",&h,&min,&sec);
for ( ; ; ) {
sleep(1);// a delay function which delays by a second
sec=sec+1;
if ( sec == 60 ) {
sec=00;
min=min+1;
}
if ( min== 60 ) {
min=00;
h=h+1;
}
if ( h==24 ) {
min=00;
sec=00;
h=00;
}
printf("The time is %02d:%02d:%02d\n",h,min,sec);
}
}
Code:
The time is 23:59:57
The time is 23:59:58
The time is 23:59:59
The time is 00:00:00
The time is 00:00:01
The time is 00:00:02
The time is 00:00:03
The time is 00:00:04
The time is 00:00:05
so how can I make it only appear in one line that updated automatically ?