Delays are often require in a program. Some examples are like -

  1. Polling for a status bit for a reguler interval
  2. Printing strings with delay in between to animate it
  3. Printing some bitmaps with delay in between to create a slide show effect
  4. Playing different sounds with intervals
  5. 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
);

You have viewed 1 page out of 248. Your C learning is 0.00% complete. Login to check your learning progress.

 Vote 0

Similar topics related to this section

printf, scanf, ioctl, mmap, DOS low level IO access, DOS BIOS int86, sleep/delay, sound, nosound, DOS graphics, Turbo C graphics,

# C Programming Language (Prentice Hall Software)
# Let Us C Paperback - 2006 by Yashavant Kanetkar
# Understanding and Using C Pointers Core techniques for memory management
# Data Structures Using C and C++ Paperback - 1998
# Data Structures In C Paperback - August 11, 2008 by Noel Kalicharan