/*
 * @topic T00320 Apr 18 -- how to classify characters
 * @brief Program demonstrates <tt>&lt;cctype&gt</tt> header and <tt>isdigit() isalpha() ispunct()</tt> functions
*/
#include <iostream>
#include <string>
#include <cctype>

using namespace std;

int main()
{
    string str = "ABC 123 @#$%";
    stringstream buffer( str );

    int onechar; // using int because char cannot represent EOF
    while ( ( onechar = cin.get() ) != EOF ) {
        if ( isdigit( onechar ) ) {
            std::cout << " [digit]";
        } else if ( isalpha( onechar ) ) {
            std::cout << " [alpha]";
        } else if ( ispunct( onechar ) ) {
            std::cout << " [punct]";
        }
        std::cout.put( str[ idx ] );
    }
    return 0;
}