Thursday, November 17, 2011

Using sleep in dev cpp

Sometime we require a screen to stay for a while and moreover we don't want to use key pressing to move, we just want to use the concept of sleep for a while then its quite easy in dev we just need to write the code :

#include <time.h>
time_t now, later;
void sleep(int delay)

"TIME.H" comes pre installed with dev cpp. So need not worry about it.

Wherever you want ot use sleep now just call

here 2 denotes the number of seconds it will sleep for. Keep in mind its seconds not milliseconds.
Now a screen can stay and move whenever you want without using keyboard.


  1. This is wait and not sleep :)

    wait consumes CPU cycles on behalf of the calling thread (something what your while loop is doing) where as sleep suspends the execution of the calling thread.

    The unistd.h library of C has a sleep method -

    This sleep implementation delegates the responsibility to the kernel using an osapi method which then suspends the thread putting it into a sleeping state.

  2. In header file WINDOWS.H

    we have Sleep(t);

    here t is time in milliseconds.

    You can use any one.

  3. Found this new website. Really helpful for the aptitude preparation tests.Must see.!!!