Kwebway Konongo <> writes:
> I'm developing an application in C; basically a linked list, with a series
> of "events" to be popped off, separated by a command to pause reading off
> the next event in the list. It has been sometime since I last did C, and
> that was the first K&R version! Is there a command to pause an app for
> a period of time, as all the commands I am familiar with specify pauses
> for integer numbers of seconds, and what I would like is fractions of a
> second, preferably milliseconds if possible
There is no good portable way to do this.
(The clock() function returns an indication of the amount of CPU time
your program has consumed. You might be tempted to write a loop that
executes until the result of the clock() function reaches a certain
value. Resist this temptation. Though it uses only standard C
features, it has at least two major drawbacks: it measures CPU time,
not wall clock time, and this kind of busy loop causes your program to
waste CPU time, possibly affecting other programs on the system.)
However, most operating systems will provide a good way to do this.
Ask in a newsgroup that's specific to whatever OS you're using, such
as comp.unix.programmer or comp.os.ms-windows.programmer.win32 -- but
see if you can find an answer in the newsgroup's FAQ first.
--
Keith Thompson (The_Other_Keith)
kst- <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.