home *** CD-ROM | disk | FTP | other *** search
/ Computerworld 1996 March / Computerworld_1996-03_cd.bin / idg_cd3 / aplikace / komunika / telixwin / tfw.5 / DETERM.SLT < prev    next >
Text File  |  1995-07-28  |  2KB  |  57 lines

  1. /****************************************************************/
  2. /*                                                              */
  3. /*  Demo of a silly terminal "game" that tells you what kind    */
  4. /*  of character you've typed in.  Character identification.    */
  5. /*                                                              */
  6. /*                   Copyright 1995 deltaComm Development, Inc. */
  7. /*                                                              */
  8. /****************************************************************/
  9.  
  10. main()
  11. {
  12. int c;
  13.  
  14. prints("Press 'q' to quit");
  15. while (c!="q")                          // while the user hasn't said "Uncle"
  16.  {
  17.   c=inkeyw();                           // Wait for a key to be pressed
  18.   if (isascii(c))                       // Check for an ASCII value (0-127)
  19.     {
  20.      if (iscntrl(c))                    // Check for a control char (0-31, 127)
  21.        printsc("Control Character");    // and if it is, tell them so.  If not,
  22.      else
  23.        if (isalnum(c))                  // Check for alphanumeric character
  24.          {                              // and if it is, is it a letter?
  25.           if (isalpha(c))               // Check for alphabet soup....
  26.             {
  27.              if (islower(c))            // Check for lower case
  28.                {
  29.                 printc(c);
  30.                 printsc(" not ");
  31.                 printc(toupper(c));     // Print in upper case
  32.                }
  33.              if (isupper(c))            // Check for upper case
  34.                {
  35.                 printc(c);
  36.                 printsc(" not ");
  37.                 printc(tolower(c));     // Print in lower case
  38.                }
  39.             }
  40.            if (isdigit(c))              // Check for a number
  41.             {
  42.              printsc("Numeral ");
  43.              printc(c);
  44.             }
  45.          }
  46.        else printsc("Not Alphanumeric");
  47.     }
  48.   else
  49.    {
  50.     printsc("Non ASCII");
  51.     cputn(c);
  52.    }
  53.   prints();
  54.  }
  55.  prints("Game Over");
  56.  }
  57.