Time

M

Michael

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
 
O

osmium

Michael said:
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
 
O

osmium

Michael said:
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.
 
G

Gianni Mariani

Michael said:
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.
 
M

Mike Wahler

osmium said:
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
 
M

Mike Wahler

Michael said:
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
 
K

Karthik Kumar

Michael said:
wut do i write in the brackets??

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/ .
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top