Thread: FAQ: How do i display current time and date ?

  1. #1
    Registered User
    Join Date
    Jan 2002
    Posts
    15

    FAQ: How do i display current time and date ?

    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
    Davie

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    Code:
    #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
    My best code is written with the delete key.

  3. #3
    Registered User
    Join Date
    Jan 2002
    Posts
    15

    Cheers

    Cheers I'll get that in my program right away thanks Davie
    Davie

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Checking array for string
    By Ayreon in forum C Programming
    Replies: 87
    Last Post: 03-09-2009, 03:25 PM
  2. Sending an email in C program
    By Moony in forum C Programming
    Replies: 28
    Last Post: 10-19-2006, 10:42 AM
  3. Read and set\change system time
    By Hexxx in forum C++ Programming
    Replies: 9
    Last Post: 01-02-2006, 07:11 AM
  4. Help: Display time and date
    By stansu in forum C++ Programming
    Replies: 5
    Last Post: 08-22-2003, 02:27 PM