//******************************************************************* // // Program: Testing Character input in a program // // Author: Art Miller, amiller@mta.ca // // Description: CS 1711 Lab 3: // // A program to demonstrate the use of character input // in C++. The operators cin >> and cin.get ( ) are explored. // // Date: October 12, 1999 // // Course Information: CS 1711 // // Filename: testchar.cpp // //********************************************************************* // #include void main () { char ch; char ch1, ch2; int ascii; char ascii_char; char new_ascii_char; int shift; cout << "Character Input to test cin >> " << endl; cout << "--------------------------------" << endl; cout << "Enter a character >"; cin >> ch; ascii = ch; cout << endl; cout << "The character grabbed by cin >> is :" << ch << endl; cout << "The ASCII value of " << ch << " is " << ascii << endl; cout << endl; cout << "Character Input to test cin.get " << endl; cout << "--------------------------------" << endl; cout << "Enter several characters >"; cin.get(ch1); ascii = ch1; cin >> ch2; cout << endl; cout << "The first character grabbed by cin.get is :" << ch1 << endl; cout << "Its ASCII value is " << ascii << endl; ascii = ch2; cout << "The next character grabbed by cin >> is :" << ch2 << endl; cout << "Its ASCII value is " << ascii << endl; cout << endl; cout << "ASCII character input" << endl; cout << "--------------------------------" << endl; cout << "Enter a single ASCII character >"; cin >> ascii_char; cout << endl; cout << "Enter a shift value >"; cin >> shift; new_ascii_char = ascii_char + shift; cout << "The char " << ascii_char << " + shift of " << shift << " gives "; cout << new_ascii_char << endl; cout << endl; }