/* * @topic T00330 Apr 18 -- how to skip digits v.2 * @brief Program demonstrates <tt><cctype></tt> header and <tt>isdigit()</tt> function */ #include <iostream> #include <string> #include <cctype> using namespace std; int main() { // This version of the program uses subscript access to // characters inside the string: string[idx] string str = "ABC 123 @#$%"; int idx = 0; for ( ; idx < str.length(); ++idx ) { if ( isdigit( str[ idx ] ) ) { continue; // skip digit } std::cout.put( str[ idx ] ); // print a non-digit character } return 0; }