Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

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;
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #check #character #integer
ADD COMMENT
Topic
Name
3+5 =