c 2b 2b98 check if character is integer

Solutions on MaxInterview for c 2b 2b98 check if character is integer by the best coders in the world

showing results for - "c 2b 2b98 check if character is integer"
Alexa
17 Mar 2016
1std::string s = "1234798797";
2std::istringstream iss(s);
3
4int num = 0;
5
6if (!(iss >> num).fail()) {
7    std::cout << num << std::endl;
8}
9else {
10    std::cerr << "There was a problem converting the string to an integer!" << std::endl;
11}
12