So my c++ program just crashed, and the error I got was:
terminate called after throwing an instance of 'std::length_error'
Use set_terminate function which sets the terminate handler function:
A terminate handler function is a function automatically called when the exception handling process has to be abandoned for some reason. This happens when a handler cannot be found for a thrown exception, or for some other exceptional circumstance that makes impossible to continue the handling process.