How to "sleep" or "delay"?

J

John

Hi all:

Is there a function to make a procedure sleep or delay for a few /seconds/minutes?

Thanks a lot.
 
J

John Carson

John Carson said:
Yes. It is called Sleep.



My mistake. Forgot what newsgroup I was in. There is no standard C++
function to do this. It is platform specific.
 
S

Sharad Kala

John said:
Hi all:

Is there a function to make a procedure sleep or delay for a few /seconds/minutes?

No standard way. Your implementation should be offering a way though.
 
J

Julie

John said:
Hi all:

Is there a function to make a procedure sleep or delay for a few /seconds/minutes?

Thanks a lot.

Not a prepackaged (standard library) fn that I'm aware of.

You could code your own pretty easily. Something to the effect of:

#include <time.h>

// ...

void sleep(time_t num_seconds)
{
const time_t start = time(NULL);
while (time(NULL) - start < num_seconds)
{
NULL;
}
}

Pretty inefficient (wastes CPU cycles), but does the trick.
 

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
474,142
Messages
2,570,818
Members
47,362
Latest member
eitamoro

Latest Threads

Top