fork(1) download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. int main() {
  6. string str;
  7.  
  8. cin >> str;
  9.  
  10. string::const_iterator it = str.begin();
  11.  
  12. while(it != str.end() && isdigit(*it))
  13. {
  14. it++;
  15. }
  16.  
  17. if (!str.empty() && it == str.end())
  18. cout << "not a string";
  19. else
  20. cout << "valid";
  21.  
  22. return 0;
  23. }
Success #stdin #stdout 0s 3276KB
stdin
123
stdout
not a string