I'm trying to create simple program that requests a user to input a number but in the upper section I display a clock that updates every second.
Here's what I know
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
int a;
int main(void) {
int a =1;
while(a)
{
system("cls");
time_t rawtime;
struct tm* time_;
time(&rawtime);
time_ = localtime(&rawtime);
printf("%i:%i:%i %i %i %i\n", time_->tm_hour, time_->tm_min,
time_->tm_sec, time_->tm_mday, time_->tm_mon+1,
time_->tm_year+1900);
printf("Give the input :");
scanf("%d",&a);
}
return 0;
}
I took the printing time code from Program a simple clock in C
What my code does is print the time and then it waits for the input, but it doesn't update the clock until I give the input.
Is there any possible way to do what I want or what keyword do I needed to search the solution? I'm sorry if my English broken, but if what I say isn't clear enough just run the code :).