Stop using old C functions, and start using C++ functionality:
std::string value = "111";
std::istringstream is(value);
if (is >> tmp)
std::cout << "OK\n";
If you want to read it from the user, then use std::cin
instead:
if (std::cin >> tmp)
std::cout << "OK\n";