Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- bool isnumber(const char *p)
- {
- for (; *p != 0; *p++)
- if (*p < '0' || *p > '9')
- return false;
- return true;
- }
- void main()
- {
- char str[20];
- while (1)
- {
- cout << "type anything: ";
- cin >> str;
- cout << "is a number ~ " << (isnumber(str) ? "true" : "false") << "\n\n";
- }
- }
Add Comment
Please, Sign In to add comment