Time

This is a discussion on Time within the C++ Programming forums, part of the General Programming Boards category; When using the time function from the header file, ctime, What should I put between the brackets? I looked at ...

  1. #1
    Registered User
    Join Date
    May 2004
    Posts
    11

    Time

    When using the time function from the header file, ctime, What should I put between the brackets? I looked at msdn online and it showed me time_t time( time_t *time) but I am not totally sure what that means. Does this visually display the time?
    Also can I use what I put in the bracket later in another function like difftime?

    Forgive me, this is my first time with the ctime function.

    Thank you in advance.

    meeloff

  2. #2
    #include<xErath.h> xErath's Avatar
    Join Date
    Jun 2004
    Posts
    722
    The time is stored in the pointed var.
    These are equivalent.
    Code:
    time_t a = time(NULL);
    
    time_t b; time(&b);
    a equals b.

  3. #3
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,801
    No, that will not visually display the time. As for the difftime you just use 2 time_t's for that and it returns the difference between the two. What are you trying to acomplish and maybe I could give you some more help
    Woop?

  4. #4
    Registered User
    Join Date
    May 2004
    Posts
    11
    so this:

    time_t a = time(NULL);
    cout<<a<<endl;

    will output the time.

  5. #5
    #include<xErath.h> xErath's Avatar
    Join Date
    Jun 2004
    Posts
    722
    Yes it will
    so as this
    Code:
    time_t a;
    time(&a);
    cout<<a<<endl;

  6. #6
    Registered User
    Join Date
    May 2004
    Posts
    11
    Thank you Very much

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to get current time
    By tsubasa in forum C Programming
    Replies: 3
    Last Post: 05-01-2009, 02:03 AM
  2. Replies: 11
    Last Post: 03-29-2009, 12:27 PM
  3. Help with assignment!
    By RVDFan85 in forum C++ Programming
    Replies: 12
    Last Post: 12-02-2006, 11:46 PM
  4. calculating user time and time elapsed
    By Neildadon in forum C++ Programming
    Replies: 0
    Last Post: 02-10-2003, 05:00 PM
  5. 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