static int string_to_int(const string &s)
{
if (s.empty())
{
printf("rd_string_to_int string is empty\n");
return -1;
}
for (size_t i = 0; i < s.size(); i++)
{
if (!isdigit(s[i]))
{
printf("%s is not a digit\n", s.c_str());
return -1;
}
}
int res;
istringstream iss(s);
iss >> res;
return res;
}