// Author: Keith Shomper // Date: 10/20/03 // Putpose: Demonstrates how to use dec, oct and hex manipulators to change the // numberic base of the output stream #include using namespace std; int main() { string s = ""; // For receiving input // Keep going until a "quit" is typed while (s[0] != 'q') { // get a string getline(cin, s, '\n'); // if the string begins with a command letter, perform that command // if the string begins with a number, then output the number // if the string is anything else, then complain switch (s[0]) { case 'd' : cout << "Switching to decimal " << dec << endl; break; case 'o' : cout << "Switching to octal " << oct << endl; break; case 'h' : cout << "Switching to hexidecimal " << hex << endl; case 'q' : break; case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : cout << atoi(s.c_str()) << endl; break; default : cout << "Input not valid, enter command or number." << endl; } } return 0; }