A simple possibility which ignores bad inputs until first integer in a string:
bool string_to_int(string str, int &x)
{
istringstream ss(str);
while (!ss.eof())
{
if (ss >> x)
return true;
ss.clear();
ss.ignore();
}
return false; // There is no integer!
}