Skip to content
doubtly

1 answer

Best answer

#include <time.h>
#include <stdio.h>
#include <conio.h>
  
int main(void)
{
    time_t current_time;
    char* c_time_string;
  
    current_time = time(NULL);
  
    if (current_time == ((time_t)-1))
    {
        printf("Error in computing current time.");
        return 1;
    }
  
     c_time_string = ctime(&current_time);
  
    if (NULL == c_time_string)
    {
        printf("Error in conversion of current time.");
        return 1;
    }
  
     printf("Current time is %s", c_time_string);
    getch();
    return 0;
}
Doubtly · 20 Jul 2022 Report
Was this answer helpful?

Your answer

Log in or create a free account to answer this question.