By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,115 Members | 2,371 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,115 IT Pros & Developers. It's quick & easy.

Time

P: n/a
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
Jul 22 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a

Michael <mi*********@blueyonder.co.uk> wrote in message
news:CV*******************@fe2.news.blueyonder.co. uk...
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

Jul 22 '05 #2

P: n/a
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.
Jul 22 '05 #3

P: n/a
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.
Jul 22 '05 #4

P: n/a
its dev-cpp the beta version

but thanx ill give it a try

"osmium" <r1********@comcast.net> wrote in message
news:2p************@uni-berlin.de...
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.

Jul 22 '05 #5

P: n/a

"osmium" <r1********@comcast.net> wrote in message
news:2p************@uni-berlin.de...
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
Jul 22 '05 #6

P: n/a
wut do i write in the brackets??

"Mike Wahler" <mk******@mkwahler.net> wrote in message
news:CD****************@newsread2.news.pas.earthli nk.net...

"osmium" <r1********@comcast.net> wrote in message
news:2p************@uni-berlin.de...
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

Jul 22 '05 #7

P: n/a

"Michael" <mi*********@blueyonder.co.uk> wrote in message
news:1V*******************@fe2.news.blueyonder.co. uk...
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
Jul 22 '05 #8

P: n/a
Michael wrote:
wut do i write in the brackets??

"Mike Wahler" <mk******@mkwahler.net> wrote in message
news:CD****************@newsread2.news.pas.earthli nk.net...
"osmium" <r1********@comcast.net> wrote in message
news:2p************@uni-berlin.de...
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.
Jul 22 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.