home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0000 - 0009 / ibm0000-0009 / ibm0003.tar / ibm0003 / LCNOW2.ZIP / EXAMPLES / CMD1.C < prev    next >
Encoding:
C/C++ Source or Header  |  1988-08-02  |  708 b   |  34 lines

  1. /*
  2.  * C M D 1
  3.  *
  4.  * Get a command from the user and take the requested action.
  5.  */
  6.  
  7. main()
  8. {
  9.     int key;
  10.  
  11.     /*
  12.      * Get a command from the user.  A command is a
  13.      * single key which is acted upon immediately.
  14.      */
  15.     printf("Command: ");
  16.     key = getch();  /* console input */
  17.     if (key == 'q' || key == 'Q')
  18.         puts("Done");
  19.     else if (key == 'h' || key == 'H' || key == '?') {
  20.         puts("CMD1 understands these commands:");
  21.         puts("h or H or ?: help frame");
  22.         puts("m or M: message");
  23.         puts("q or Q: quit");
  24.     }
  25.     else if (key == 'm' || key == 'M') {
  26.         puts("Here's the message.");
  27.         puts("Pretty disappointing, huh!");
  28.     }
  29.     else
  30.         printf("Unknown command -- %c\n", key);
  31.  
  32.     return (0);
  33. }
  34.