I'm currently writing a gradebook application in which the user would enter grades and I would store them in an array. When the user enters "exit", the program exits and prints out a histogram of the entries the user entered. However, when I enter "exit" into my program, the console tells me abort() has been called. Is there a way around this?
Pretty sure the problem is line 22, if you enter "exit", line 22 will try run stoi("exit"), which would either cause some exception or undefined behavior.
Change line 15-17 to be
1 2 3 4
if (user_input == "exit"){
printArray(string_array, 10);
break;
}
would probably be the easiest way to remedy this, but just note that excessive use for things like "break;" or "continue;" can make code hard to navigate when debugging.