FAQ: How do i display current time and date ? [Archive] - C Board

PDA

View Full Version : FAQ: How do i display current time and date ?


davie_scotland
01-24-2002, 11:02 AM
Hi, I was looking for a bit of help. I'm just starting to learn C and as part of my course I'm to produce a menu driven system to hold race times and competitor details. I'm struggling a bit on several aspects of. I was wondering if anyone could help me to display the current time and date on some of the screens of my menu. I am using the printf function to display text i would be very grateful for any help Cheers Davie

Prelude
01-24-2002, 11:09 AM
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main(void)
{
time_t now;
time(&now);

printf("%s", ctime(&now));

return EXIT_SUCCESS;
}

-Prelude

davie_scotland
01-24-2002, 11:18 AM
Cheers I'll get that in my program right away thanks Davie