home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / c / other / learn / switch.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-10-07  |  447 b   |  26 lines

  1. /* SWITCH.C: Demonstrate switch statement. */
  2.  
  3. #include <stdio.h>
  4. #include <conio.h>
  5. #define  B_KEY  'b'
  6. #define  ENTER_KEY  '\r'
  7.  
  8. main()
  9. {
  10.    char ch;
  11.    printf( "Press the b key to hear a bell.\n" );
  12.    ch = getch();
  13.    switch( ch )
  14.    {
  15.       case B_KEY:
  16.      printf( "Beep!\a\n" );
  17.      break;
  18.       case ENTER_KEY:
  19.      printf( "What a boring selection...\n" );
  20.      break;
  21.       default:
  22.      printf( "Bye bye." );
  23.      break;
  24.    }
  25. }
  26.