A simple clock in C

So My goal was to make a simple clock in C++ but I had also been advised to use C so I have made two clocks that do the exact same thing. This is the C version and the next post is the C++ version.

#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <time.h>

int main(int argc, char** argv) {
A:

    time_t now = time(0);
    tm *ltm = localtime(&now);
    
    printf("Day: %d\nMonth: %d\nYear: %d\n", ltm->tm_mday, ltm->tm_mon, ltm->tm_year);
    printf("Time: %02d:%02d:%02d\n", ltm->tm_hour, ltm->tm_min, ltm->tm_sec);
    
    correct\n";
    printf("The time is correct as long as your system is correct\n");

    sleep(1);
    system("clear");

    goto A;
}

Related Post

Leave a Reply

Your email address will not be published.