using namespace std; #include #include void Replace (char c, char* t); void Replace (char c, char* t) // Returns with: // t = " SPACE " whenever c is a space character // t = " TAB " whenever c is a tab character // t = " NEWLINE " whenever c is a newline character // t = a string containing only the character c otherwise { switch (c) { case '\t': strcpy (t, " TAB "); break; case ' ': strcpy (t, " SPACE "); break; case '\n': strcpy (t, " NEWLINE "); break; default: t[0] = c; t[1] = '\0'; break; } } int main () { // Process input one character at a time, making replacements as // required while (true) { char character_from_input; char text_to_output[10]; // Quit when no more input if (! cin.get (character_from_input)) break; // Process one character Replace (character_from_input, text_to_output); cout << text_to_output; } }