How do i use add time?

This is a discussion on How do i use add time? within the C++ Programming forums, part of the General Programming Boards category; How do i put time in my programs? Do you have to use time.h and what functions should i use?...

  1. #1
    Registered User
    Join Date
    Nov 2002
    Posts
    8

    How do i use add time?

    How do i put time in my programs? Do you have to use time.h and what functions should i use?

  2. #2
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,659
    This code will initialize and return to the variable "Time" a pointer to a struct tm containing the current time. Just look in time.h and examine this "tm" structure to see what fields are there to extract.

    Hope this helps.

    Code:
    struct tm *Time;
    time_t timenow;
    time(&timenow);
    Time = localtime(&timenow);



    ITSA
    Socket Library!

  3. #3
    Registered User
    Join Date
    Sep 2002
    Posts
    72
    Code:
    #include <time.h>
    #include <iostream.h>
    int main(void)
    
    {
    
          time_t t = time(NULL);   //calls time function
          cout << ctime(&t) << endl;   //display of time
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Journey time prog 1 minute wrong
    By mike_g in forum C Programming
    Replies: 4
    Last Post: 10-12-2006, 03:41 AM
  2. Time conversions
    By mariabair in forum C++ Programming
    Replies: 2
    Last Post: 01-02-2004, 03:55 PM
  3. calculating user time and time elapsed
    By Neildadon in forum C++ Programming
    Replies: 0
    Last Post: 02-10-2003, 05:00 PM
  4. time class
    By Unregistered in forum C++ Programming
    Replies: 1
    Last Post: 12-11-2001, 09:12 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21