Delays are often require in a program. Some examples are like -
- Polling for a status bit for a reguler interval
- Printing strings with delay in between to animate it
- Printing some bitmaps with delay in between to create a slide show effect
- Playing different sounds with intervals
- Stall the execution for ever till some signal/event comes
Many other combinations are possible in games and animation programs. So delay/sleep API library function can be used for this.
We should remember that delay is handled in task scheduler and thus it is operting system dependent. Followings are ways to execute delays in Windows, Linux and DOS.Windows:
#include <windows.h> VOID WINAPI Sleep( _In_ DWORD dwMilliseconds );Linux:
#include <unistd.h> unsigned int sleep(unsigned int seconds);DOS:
#include <process.h> VOID WINAPI delay( _In_ DWORD dwMilliseconds );
About our authors: Team EQA
You have viewed 1 page out of 248. Your C learning is 0.00% complete. Login to check your learning progress.
Learn on Youtube