Answers for "how to check if character is a number in c++"

C++
0

c++ check if char is number

char c = '1';
bool result = isdigit(c);
cout << result << endl; //1
Posted by: Guest on September-05-2020
0

c++98 check if character is integer

std::string s = "1234798797";
std::istringstream iss(s);

int num = 0;

if (!(iss >> num).fail()) {
    std::cout << num << std::endl;
}
else {
    std::cerr << "There was a problem converting the string to an integer!" << std::endl;
}
Posted by: Guest on October-04-2020

Code answers related to "how to check if character is a number in c++"

Browse Popular Code Answers by Language