I've met this code:
std::string str;
std::getline(std::cin, str);
std::string sub = str.substr(str.find('.') + 1);
first reaction was - this is invalid code. But after some thoughts it seems to be not so simple. So is it valid C++ expression (has predictable behavior)?
PS if it is not so clear question is mostly related to what will happen when '.' would not be found in str
, but not limited to that, as there could be other issues.