Difference between delay() and sleep() in C? -


both delay() , sleep() function suspends system amount of time, delay takes milisecond argument while sleep takes second argument. besides this, there differences between these 2 functions? , among them, gives more accurate result?

they same thing except 1 sleeps number of seconds while other sleeps milliseconds.

you should go reference std::this_thread::sleep_for:

std::this_thread::sleep_for 

instead in c++ if can. windows.h have sleep , unix have usleep.

this implementation found online might better fit needs:

#if defined(__win32__) || defined(_win32) || defined(win32) || defined(__windows__) || defined(__tos_win__)    #include <windows.h>    inline void delay( unsigned long ms )     {     sleep( ms );     }  #else  /* presume posix */    #include <unistd.h>    inline void delay( unsigned long ms )     {     usleep( ms * 1000 );     }  #endif 

Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -

Nuget pack csproj using nuspec -