Std::stoi Causing exception

Another easy way around this, if you don’t want to do the proper handling of exception as Todd suggests, is to use the C routine ‘atoi’ on an array of chars (as opposed to using the C++ routine for std::string): in this case if it can’t convert the input, it just produces 0. See the reference.
You just need to first make a C-string out of the std::string, but that’s easy.
Hope it helps!