Help with C++ <ctime>

Discussion in 'C++' started by B Williams, Jul 10, 2006.

  1. B Williams

    B Williams Guest

    I have been searching the internet trying to find the definition for the
    function time() in the standard library header <ctime>. Can someone help me
    with this? Thanks in advance.
    B Williams, Jul 10, 2006
    #1
    1. Advertising

  2. B Williams

    Alan Johnson Guest

    B Williams wrote:
    > I have been searching the internet trying to find the definition for the
    > function time() in the standard library header <ctime>. Can someone help me
    > with this? Thanks in advance.
    >
    >


    std::clock_t std::time(std::clock_t * tloc) ;

    Returns the number of seconds since the Epoch (midnight, Jan 1, 1970).
    If tloc is not NULL, it also writes the same value to the location
    provided by the parameter.

    --
    Alan Johnson
    Alan Johnson, Jul 10, 2006
    #2
    1. Advertising

  3. B Williams

    B Williams Guest

    "Alan Johnson" <> wrote in message
    news:e8sc9d$8cl$...
    >B Williams wrote:
    >> I have been searching the internet trying to find the definition for the
    >> function time() in the standard library header <ctime>. Can someone help
    >> me with this? Thanks in advance.

    >
    > std::clock_t std::time(std::clock_t * tloc) ;
    >
    > Returns the number of seconds since the Epoch (midnight, Jan 1, 1970). If
    > tloc is not NULL, it also writes the same value to the location provided
    > by the parameter.
    >
    > --
    > Alan Johnson
    >

    Thanks Alan,
    I really appreciate it.
    B Williams, Jul 10, 2006
    #3
  4. B Williams

    Default User Guest

    B Williams wrote:

    > I have been searching the internet trying to find the definition for
    > the function time() in the standard library header <ctime>. Can
    > someone help me with this? Thanks in advance.



    What do you mean by "definition"?




    Brian
    Default User, Jul 10, 2006
    #4
  5. B Williams

    Jack Klein Guest

    On Sun, 09 Jul 2006 18:59:09 -0700, Alan Johnson
    <> wrote in comp.lang.c++:

    > B Williams wrote:
    > > I have been searching the internet trying to find the definition for the
    > > function time() in the standard library header <ctime>. Can someone help me
    > > with this? Thanks in advance.
    > >
    > >

    >
    > std::clock_t std::time(std::clock_t * tloc) ;
    >
    > Returns the number of seconds since the Epoch (midnight, Jan 1, 1970).
    > If tloc is not NULL, it also writes the same value to the location
    > provided by the parameter.


    time() returns type time_t.

    clock() returns type clock_t.

    --
    Jack Klein
    Home: http://JK-Technology.Com
    FAQs for
    comp.lang.c http://c-faq.com/
    comp.lang.c++ http://www.parashift.com/c -faq-lite/
    alt.comp.lang.learn.c-c++
    http://www.contrib.andrew.cmu.edu/~ajo/docs/FAQ-acllc.html
    Jack Klein, Jul 10, 2006
    #5
  6. B Williams

    Alan Johnson Guest

    Jack Klein wrote:
    > On Sun, 09 Jul 2006 18:59:09 -0700, Alan Johnson
    > <> wrote in comp.lang.c++:
    >
    >> B Williams wrote:
    >>> I have been searching the internet trying to find the definition for the
    >>> function time() in the standard library header <ctime>. Can someone help me
    >>> with this? Thanks in advance.
    >>>
    >>>

    >> std::clock_t std::time(std::clock_t * tloc) ;
    >>
    >> Returns the number of seconds since the Epoch (midnight, Jan 1, 1970).
    >> If tloc is not NULL, it also writes the same value to the location
    >> provided by the parameter.

    >
    > time() returns type time_t.
    >
    > clock() returns type clock_t.
    >


    Correct. Apologies for the misinformation.

    --
    Alan Johnson
    Alan Johnson, Jul 10, 2006
    #6
  7. B Williams

    Default User Guest

    Alan Johnson wrote:

    > B Williams wrote:
    > > I have been searching the internet trying to find the definition
    > > for the function time() in the standard library header <ctime>.
    > > Can someone help me with this? Thanks in advance.

    >
    > std::clock_t std::time(std::clock_t * tloc) ;
    >
    > Returns the number of seconds since the Epoch (midnight, Jan 1,
    > 1970). If tloc is not NULL, it also writes the same value to the
    > location provided by the parameter.


    As Jack mentioned, this is the wrong declaration. You are also
    incorrect in the semantics. There's no requirement that time() return
    seconds, certainly not seconds since the epoch. That happens to be
    common, but portable should not rely on that or need that.



    Brian
    Default User, Jul 10, 2006
    #7
  8. B Williams

    Guest

    You can locate the ctime header file using "locate" or "find" commands
    on UNIX

    Thanks and regards
    SJ

    Default User wrote:
    > B Williams wrote:
    >
    > > I have been searching the internet trying to find the definition for
    > > the function time() in the standard library header <ctime>. Can
    > > someone help me with this? Thanks in advance.

    >
    >
    > What do you mean by "definition"?
    >
    >
    >
    >
    > Brian
    , Jul 10, 2006
    #8
  9. B Williams

    Ron Natalie Guest

    Default User wrote:

    >
    > As Jack mentioned, this is the wrong declaration. You are also
    > incorrect in the semantics. There's no requirement that time() return
    > seconds, certainly not seconds since the epoch. That happens to be
    > common, but portable should not rely on that or need that.
    >

    Correct, time_t's encoding is not specified. All you can do is
    pass it to otherf unctions. If you want to know elapsed time
    from some point, use difftime().
    Ron Natalie, Jul 10, 2006
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ernst Murnleitner

    replacement for <ctime>?

    Ernst Murnleitner, Jul 16, 2003, in forum: C++
    Replies:
    8
    Views:
    538
    Limech
    Jul 20, 2003
  2. Tivo Escobar

    Question about ctime

    Tivo Escobar, Jul 23, 2003, in forum: C++
    Replies:
    1
    Views:
    395
    Victor Bazarov
    Jul 23, 2003
  3. Oplec
    Replies:
    2
    Views:
    513
    Oplec
    Oct 26, 2003
  4. Kevin

    ctime Help

    Kevin, May 16, 2004, in forum: C++
    Replies:
    3
    Views:
    790
    osmium
    May 16, 2004
  5. wukexin
    Replies:
    1
    Views:
    473
    Karl Heinz Buchegger
    May 25, 2005
Loading...

Share This Page