fork(1) download
  1. #include <algorithm>
  2. #include <cassert>
  3. #include <cctype>
  4. #include <string>
  5.  
  6. bool is_number(const std::string &s) {
  7. return !s.empty() && std::all_of(s.begin(), s.end(), ::isdigit);
  8. }
  9.  
  10. int main() {
  11. assert(!is_number(""));
  12. assert(is_number("123"));
  13. assert(!is_number("123abc"));
  14. }
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout

Standard output is empty