/* --------------------------------------------------------------------- * GETKEY3.C Read keyboard character without echo, convert * to upper case and display to Standard Output * * "3rd Generation" Programming Language demo for CIS 120 * Duplicate as near as possible Machine Language and Assembly Language * versions created with DEBUG. * Note that the library function toupper() only makes the conversion * to uppercase if the character is lower case, so the * if ( islower( ch ) ) is not strictly needed, but it shows the high- * level language version of the same code in assembly. * * Mike Huffman, Portland Community College * Computer Information Systems, Winter Term, 2001 * * Last update: 10 FEB 2001 * --------------------------------------------------------------------- */ #include /* putchar() */ #include /* getch() */ #include /* toupper(), islower() */ /* all C/C++ programs have a main() function that return an integer * value to the operating system, 0 is the usual "success" code */ int main() { int ch; /* keyboard character */ do { /* loop at least once */ ch = getch(); /* read char from keyboard */ if ( islower( ch ) ) /* if char is lower case */ ch = toupper( ch ); /* convert to upper case */ /* display the character; a "real" program would now use the * upper case character to make, say, menu choices */ putchar( ch ); } while ( ch != 'Q' ); /* loop until char = 'Q' */ return 0; /* return success code to DOS */ }