home *** CD-ROM | disk | FTP | other *** search
/ C Programming Starter Kit 2.0 / SamsPublishing-CProgrammingStarterKit-v2.0-Win31.iso / tyc / list7_1.c < prev    next >
C/C++ Source or Header  |  1993-10-16  |  1KB  |  58 lines

  1.    /* Demonstration of frequently used escape sequences */
  2.  
  3.    #include <stdio.h>
  4.  
  5.    #define QUIT  3
  6.  
  7.    int  get_menu_choice( void );
  8.    void print_report( void );
  9.  
  10.   main()
  11.   {
  12.       int choice = 0;
  13.   
  14.       while( choice != QUIT )
  15.       {
  16.          choice = get_menu_choice();
  17.   
  18.          if( choice == 1 )
  19.              printf( "\nBeeping the computer\a\a\a" );
  20.          else
  21.          {
  22.              if( choice == 2 )
  23.                  print_report();
  24.          }
  25.       }
  26.       printf( "You chose to quit!" );
  27.   }
  28.   
  29.   int get_menu_choice( void )
  30.   {
  31.       int selection = 0;
  32.  
  33.       do
  34.       {
  35.           printf( "\n" );
  36.           printf( "\n1 - Beep Computer" );
  37.           printf( "\n2 - Display Report");
  38.           printf( "\n3 - Quit");
  39.           printf( "\n" );
  40.           printf( "\nEnter a selection:" );
  41.  
  42.           scanf( "%d", &selection );
  43.  
  44.        }while ( selection < 1 || selection > 3 );
  45.  
  46.        return selection;
  47.   }
  48.  
  49.   void print_report( void )
  50.   {
  51.        printf( "\nSAMPLE REPORT" );
  52.        printf( "\n\nSequence\tMeaning" );
  53.        printf( "\n=========\t=======" );
  54.        printf( "\n\\a\t\tbell (alert)" );
  55.        printf( "\n\\b\t\tbackspace" );
  56.        printf( "\n...\t\t...");
  57.   }
  58.