Showing formatted date/time
Shows how to display the date and time in a pleasent format
AI
Resumen de IA: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.
Código fuente
/* shows how to display the system time * coded by jason m * 30/06/03 * [[email protected]] */ #include<stdio.h> #include<time.h> int main(void) { char days[][10] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" }; char months[][20] = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }; time_t tme; struct tm *system_time; tme = time(NULL); /* get the sys time in system calender format */ system_time = localtime(&tme); /* system_time will point to a tm structure created by * the compiler */ printf("The current time is: %.2d:%.2d:%.2d\n", system_time->tm_hour, system_time->tm_min, system_time->tm_sec); printf("The current date is: %s %d %s %d \n", days[system_time->tm_wday], system_time->tm_mday, months[system_time->tm_mon], (system_time->tm_year + 1900)); return 0; }
Comentarios originales (3)
Recuperado de Wayback Machine