westron

otvet.mail.ru

Apr 14th, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.34 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. bool isnumber(const char *p)
  5. {
  6.     for (; *p != 0; *p++)
  7.         if (*p < '0' || *p > '9')
  8.             return false;
  9.     return true;
  10. }
  11.  
  12. void main()
  13. {
  14.     char str[20];
  15.     while (1)
  16.     {
  17.         cout << "type anything: ";
  18.         cin >> str;
  19.         cout << "is a number ~ " << (isnumber(str) ? "true" : "false") << "\n\n";
  20.     }
  21. }
Add Comment
Please, Sign In to add comment