Time

Discussion in 'C++' started by Michael, Aug 29, 2004.

  1. Michael

    Michael Guest

    im new to this c++ programming
    im making a game and need to workout how to do certain things like run
    functions at a certain time after the program has run
    eg after 10 seconds run the pen function

    can anyone help please??

    thanx michael
    Michael, Aug 29, 2004
    #1
    1. Advertising

  2. Michael

    osmium Guest

    Michael <> wrote in message
    news:CVlYc.43461$...
    > im new to this c++ programming
    > im making a game and need to workout how to do certain things like run
    > functions at a certain time after the program has run
    > eg after 10 seconds run the pen function
    >
    > can anyone help please??
    >
    > thanx michael
    >
    >
    osmium, Aug 29, 2004
    #2
    1. Advertising

  3. Michael

    osmium Guest

    Michael writes:

    > im new to this c++ programming
    > im making a game and need to workout how to do certain things like run
    > functions at a certain time after the program has run
    > eg after 10 seconds run the pen function


    Sorry for the blank post.

    C++ comes with functions cclock() and ctime() which may be helpful. But
    your particular compiler may have something better which probably has
    "sleep" somehow suggested by the name. So if you don't like cclock or ctime
    and you can't find anything better with that hint, post to a newsgroup for
    your particular compiler.
    osmium, Aug 29, 2004
    #3
  4. Re: Time {OT response]

    Michael wrote:
    > im new to this c++ programming
    > im making a game and need to workout how to do certain things like run
    > functions at a certain time after the program has run
    > eg after 10 seconds run the pen function
    >
    > can anyone help please??


    Apart from the standard facilities provided by the compiler (as
    mentioned in the previous post), you may find other facilities provided
    by the OS might be more interesting.

    Unix has an "alarm" method that will cause a signal to be sent as well
    as various other timer facilities.

    If you don't need asynchronous timing, you mat be able to use the
    "select" or "poll" system calls that allow you to both wait on input and
    a timeout.

    All of these facilities require quite a significant understanding of how
    they interact with the C++ library - not somthing a beginner will find
    trivial.
    Gianni Mariani, Aug 29, 2004
    #4
  5. Michael

    Michael Guest

    its dev-cpp the beta version

    but thanx ill give it a try

    "osmium" <> wrote in message
    news:...
    > Michael writes:
    >
    > > im new to this c++ programming
    > > im making a game and need to workout how to do certain things like run
    > > functions at a certain time after the program has run
    > > eg after 10 seconds run the pen function

    >
    > Sorry for the blank post.
    >
    > C++ comes with functions cclock() and ctime() which may be helpful. But
    > your particular compiler may have something better which probably has
    > "sleep" somehow suggested by the name. So if you don't like cclock or

    ctime
    > and you can't find anything better with that hint, post to a newsgroup for
    > your particular compiler.
    >
    >
    Michael, Aug 29, 2004
    #5
  6. Michael

    Mike Wahler Guest

    "osmium" <> wrote in message
    news:...
    > Michael writes:
    >
    > > im new to this c++ programming
    > > im making a game and need to workout how to do certain things like run
    > > functions at a certain time after the program has run
    > > eg after 10 seconds run the pen function

    >
    > Sorry for the blank post.
    >
    > C++ comes with functions cclock() and ctime()


    That's clock() and time(). Declared by header <ctime>
    (or <time.h>).

    -Mike
    Mike Wahler, Aug 29, 2004
    #6
  7. Michael

    Michael Guest

    wut do i write in the brackets??

    "Mike Wahler" <> wrote in message
    news:CDsYc.2085$...
    >
    > "osmium" <> wrote in message
    > news:...
    > > Michael writes:
    > >
    > > > im new to this c++ programming
    > > > im making a game and need to workout how to do certain things like run
    > > > functions at a certain time after the program has run
    > > > eg after 10 seconds run the pen function

    > >
    > > Sorry for the blank post.
    > >
    > > C++ comes with functions cclock() and ctime()

    >
    > That's clock() and time(). Declared by header <ctime>
    > (or <time.h>).
    >
    > -Mike
    >
    >
    Michael, Aug 29, 2004
    #7
  8. Michael

    Mike Wahler Guest

    "Michael" <> wrote in message
    news:1VsYc.49020$...
    > wut do i write in the brackets??


    [Please don't top post.] What do you mean by
    your question? Do you mean "how do I use those
    functions?" If so, you need a standard library
    reference so you can look them up. This could
    be from a textbook or from your compiler documentation.
    For C++ books, see www.accu.org for reviews and
    recommendations.

    -Mike
    Mike Wahler, Aug 30, 2004
    #8
  9. Michael wrote:

    > wut do i write in the brackets??
    >
    > "Mike Wahler" <> wrote in message
    > news:CDsYc.2085$...
    >
    >>"osmium" <> wrote in message
    >>news:...
    >>
    >>>Michael writes:
    >>>
    >>>
    >>>>im new to this c++ programming
    >>>>im making a game and need to workout how to do certain things like run
    >>>>functions at a certain time after the program has run
    >>>>eg after 10 seconds run the pen function
    >>>
    >>>Sorry for the blank post.
    >>>
    >>>C++ comes with functions cclock() and ctime()

    >>
    >>That's clock() and time(). Declared by header <ctime>
    >>(or <time.h>).
    >>
    >>-Mike
    >>


    There are two levels of granularities here - in terms of seconds and
    clocks.

    CLK_TCK macro would get the number of clock ticks per second.

    So depending on your profiling necessity, you can choose from one of
    the two.

    Aliter:
    This link might be helpful ..

    http://www.cplusplus.com/ref/ctime/ .


    --
    Karthik.
    Karthik Kumar, Sep 1, 2004
    #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. engsol
    Replies:
    2
    Views:
    928
    Dan Bishop
    Jan 26, 2004
  2. Replies:
    8
    Views:
    460
    Magnus Lycka
    Aug 5, 2005
  3. Peter Hansen
    Replies:
    0
    Views:
    702
    Peter Hansen
    Feb 22, 2006
  4. Peter Hansen
    Replies:
    0
    Views:
    596
    Peter Hansen
    Feb 22, 2006
  5. flamesrock
    Replies:
    8
    Views:
    434
    Hendrik van Rooyen
    Nov 24, 2006
Loading...

Share This Page