Convert tm structure to string: how to use asctime
#include <stdio.h> #include <time.h> int main () { time_t rawtime; struct tm *timeinfo; time ( &rawtime ); timeinfo = localtime ( &rawtime ); printf ( "Current date and time are: %s", asctime (timeinfo) ); return 0; }