home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / qc_prog / chap06 / alert.c next >
Encoding:
C/C++ Source or Header  |  1988-04-05  |  734 b   |  27 lines

  1. /* alert.c -- sounds alarm by calling a        */
  2. /*            beep() function with a parameter */
  3.  
  4. main()
  5. {
  6.     void beep(times);  /* function declaration */
  7.     printf("*** Alert! Alert! ***\n");
  8.     beep(3);     /* call beep() with parameter */
  9. }
  10.  
  11. void beep(times)
  12.     int times;   /* declare function parameter */
  13. {
  14.     int count;
  15.  
  16.     /* check that parameter is between 1 and 4 */
  17.     if ((times < 1) || (times > 4))
  18.         {
  19.         printf("Error in beep(): %d beeps specified.\n",
  20.                 times);
  21.         printf("Specify one to four beeps");
  22.         }
  23.     else /* sound the beeps */
  24.         for (count = 1; count <= times; count++)
  25.             printf("\a");  /* "alert" escape sequence */
  26. }
  27.