/****************************************************************/
/* */
/* Demo of a silly terminal "game" that tells you what kind */
/* of character you've typed in. Character identification. */
/* */
/* Copyright 1995 deltaComm Development, Inc. */
/* */
/****************************************************************/
main()
{
int c;
prints("Press 'q' to quit");
while (c!="q") // while the user hasn't said "Uncle"
{
c=inkeyw(); // Wait for a key to be pressed
if (isascii(c)) // Check for an ASCII value (0-127)
{
if (iscntrl(c)) // Check for a control char (0-31, 127)
printsc("Control Character"); // and if it is, tell them so. If not,
else
if (isalnum(c)) // Check for alphanumeric character
{ // and if it is, is it a letter?
if (isalpha(c)) // Check for alphabet soup....
{
if (islower(c)) // Check for lower case
{
printc(c);
printsc(" not ");
printc(toupper(c)); // Print in upper case
}
if (isupper(c)) // Check for upper case
{
printc(c);
printsc(" not ");
printc(tolower(c)); // Print in lower case
}
}
if (isdigit(c)) // Check for a number
{
printsc("Numeral ");
printc(c);
}
}
else printsc("Not Alphanumeric");
}
else
{
printsc("Non ASCII");
cputn(c);
}
prints();
}
prints("Game Over");
}