Advertisement
obernardovieira

std::isdigit [ tutorial ]

Jul 31st, 2013
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.42 KB | None | 0 0
  1. #include <iostream>
  2. #include <locale>
  3. #include <string>
  4.  
  5. bool main() {
  6.     std::string text("Number 5 is the best!");
  7.     std::locale loc;
  8.    
  9.     for(unsigned short int len = 0; len != text.length(); len++) {
  10.         if(!std::isdigit(text[len],loc)) {
  11.             std::cout << text[len] << " is not a number" << std::endl;
  12.         }
  13.         else {
  14.             std::cout << text[len] << " is a number" << std::endl;
  15.         }
  16.     }
  17.     system("pause");
  18.     return true;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement