c++ string
#include <iostream> #include <cctype> #include <string> using namespace std; int main() { char next; string message="All good!\n"; cin.get(next); while (cin.get(next) && (next != '\n')) { if (! isdigit(next)) message = "There's a non-number in here! \n"; } cout << message << endl; return 0; } #include <cstdlib> #include <string> #include <iostream> using namespace std; int main() { char next; string setofnums = "0123456789"; string email; cin >> email; if (email.find_first_not_of(setofnums) != string::npos) cout << "There's a non-number in here! \n"; else cout << "All good!\n"; return 0; }