/* * @topic T00335 Apr 18 -- how to skip digits v.3 * @brief Program demonstrates <tt><sstream></tt> and <tt><cctype></tt> headers and <tt>isdigit()</tt> function */ #include <iostream> #include <string> #include <sstream> #include <cctype> using namespace std; int main() { // This version of the program uses memory buffer string str = "ABC 123 @#$%"; stringstream buffer( str ); // print everything except digits int onechar; // using int because char cannot represent EOF while ( ( onechar = buffer.get() ) != EOF ) { if ( isdigit( onechar ) ) { continue; // skip digit } std::cout.put( onechar ); // print a non-digit character } return 0; }