#include #include int main( void ) { char ch; long nwhite = 0, nalpha = 0, ndigit = 0, npunct = 0, nother = 0, total = 0; while ( std::cin.get( ch ) ) { ++total; if ( isspace( ch ) ) ++nwhite; else if ( isalpha( ch ) ) ++nalpha; else if ( isdigit( ch ) ) ++ndigit; else if ( ispunct( ch ) ) ++npunct; else ++nother; std::cout << ch; } std::cout << "whitespace: " << nwhite << '\n' << "digits: " << ndigit << '\n' << "letters: " << nalpha << '\n' << "punctuation: " << npunct << '\n'; if ( nother ) std::cout << "other chars: " << nother << '\n'; std::cout << "total chars: " << total << '\n'; }