fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <algorithm>
  4. #include <ctype.h> // for http://w...content-available-to-author-only...s.com/reference/cctype/isdigit/
  5.  
  6. int main()
  7. {
  8. std::string str = "HelloTheir453Their54Hello" ;
  9.  
  10. // loop
  11. for( char& c : str ) if( ::isdigit(c) ) c = '*' ;
  12. std::cout << str << '\n' ;
  13.  
  14. str = "cvvc2hvc7r6464677VJVJvju78uR&R56fuvfcJv" ;
  15.  
  16. // algorithm http://w...content-available-to-author-only...s.com/reference/algorithm/replace_if/
  17. std::replace_if( str.begin(), str.end(), ::isdigit, '*' ) ;
  18. std::cout << str << '\n' ;
  19. }
  20.  
Success #stdin #stdout 0s 2984KB
stdin
Standard input is empty
stdout
HelloTheir***Their**Hello
cvvc*hvc*r*******VJVJvju**uR&R**fuvfcJv