I need to help: C or plus

MaDHaVoK

Senior member
Mar 7, 2001
601
0
0
I am trying to get a loop to execute every .1 seconds so I can make a timer... I cannot find anything on the web........
 

MaDHaVoK

Senior member
Mar 7, 2001
601
0
0
forgot... I am trying to write this in C but I could pull off C++ if I had to....


Is any of this good?
nanosleep?
clk_tck?
clock()

ARG

Thanks
 
Jan 24, 2002
52
0
0
Sleep(n);
will make your loop pause for a specified number of time. where n is the number in ms (for .1 second, n=100).

be sure to #include <windows.h>
 

MaDHaVoK

Senior member
Mar 7, 2001
601
0
0
Thanks.. sleep(1); actually delays for 1 second and sleep(.1) delays for 1/100 of a second! I don't get it!!
 

N8Magic

Lifer
Dec 12, 2000
11,624
1
81


<< Thanks.. sleep(1); actually delays for 1 second and sleep(.1) delays for 1/100 of a second! I don't get it!! >>



(n) is milliseconds. There are 1000 milliseconds in a second.

Therefore to pause for 1 second: sleep(1000)
To pause for .1 second : sleep(100)
To pause for .332 second: sleep(332)
etc...