#include <time>

This is a discussion on #include <time> within the C++ Programming forums, part of the General Programming Boards category; do i need to use time as a variable type; is it defined for that type of use? Code: #include ...

  1. #1
    Or working on it anyways mramazing's Avatar
    Join Date
    Dec 2005
    Location
    Lehi, UT
    Posts
    121

    #include <time>

    do i need to use time as a variable type; is it defined for that type of use?

    Code:
    #include <time.h>
    
    // aditional code
    
    int main(void)
    {
         time_t // or do i just use time and then say stuff like time now, start, finish
         // additional code
    }

  2. #2
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    time_t is NOT a variable, but it is a typedef for an unsigned int. So what you posted is the same as this
    Code:
    int main
    {
       unsigned int  <<<wrong
    }
    This is incorrect because you did not specify a variable name
    Code:
    int main
    {
       time_t today;  <<<right
    }

  3. #3
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >but it is a typedef for an unsigned int
    Amazing that you can somehow divine the underlying type when even the standard isn't specific. I'm impressed.
    My best code is written with the delete key.

  4. #4
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,487
    time is a function. time_t is a type as is clock_t and the struct tm.
    http://www.cplusplus.com/ref/ctime/

    Also, use #include <ctime>.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  5. #5
    Hardware Engineer
    Join Date
    Sep 2001
    Posts
    1,398
    If you haven't learned about structures yet, you need to understand them first.

    There's some <ctime> information in the cprogramming.com FAQ too.

  6. #6
    Or working on it anyways mramazing's Avatar
    Join Date
    Dec 2005
    Location
    Lehi, UT
    Posts
    121
    well ty i read a little more, i am teaching myself and without seeing code, it can be difficult. Anyway i got it i have read about typedef's

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 48
    Last Post: 09-26-2008, 03:45 AM
  2. MFC include BS
    By VirtualAce in forum Windows Programming
    Replies: 4
    Last Post: 10-31-2005, 11:44 AM
  3. help with finding lowest number entered
    By volk in forum C++ Programming
    Replies: 12
    Last Post: 03-22-2003, 12:21 PM
  4. #includes don't seem to be working
    By Inquirer in forum C++ Programming
    Replies: 12
    Last Post: 08-05-2002, 05:38 PM
  5. MFC Assertion Failure
    By maxthecat in forum Windows Programming
    Replies: 5
    Last Post: 08-01-2002, 09:58 AM

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