#include #include /************************************************************************** Copyright 2005 by Andre Jones. Edited version: Added formatting and indentation. A short ascii conversion program. ** intc() function needs to be fixed. Written by Andre Jones *************************************************************************** This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *****************************************************************************/ using namespace std; void charc() { // The "convert character to ascii chart number" function. char y; cout << "Enter character: " << endl; cin >> y; cout << "The ascii chart number for "; cout << y << " will be: " << static_cast( y ) << endl; } void intc() { // Function for converting integers to the ascii chart number. // Still under construction. int f; cout << "Enter number: " << endl; cin >> f; cout << "The ascii chart number for " << f << " will be: " << endl; cout << static_cast( f ) << endl; } void conv1() { // Function for converting ascii chart number to it's character int x; cout << "Enter ascii chart number: " << endl; cin >> x; cout << "Your value will be: " << static_cast( x ) << endl; } void conv2() { // Function for converting letter or number into ascii chart num. string ans; cout << "Do you have a number?" << endl; cin >> ans; if ( ans == "yes" ) { // This is used instead of the original strcmp intc(); } else { cout << "You must have a character to convert then" << endl; charc(); } } int main() { int x; cout << "1: Convert number on ascii chart to it's output" << endl; cout << "2: Convert letter or number into ascii chart number " << endl; cout << "0: quit " << endl; int input; cin >> input; switch ( input ) { case 1: conv1(); break; case 2: conv2(); break; default: return 0; break; } cin.get(); }