Exception Handling

Hi, I just recently read about handling exceptions and I can't get it to work

ship_setup is an array, 'moves' is an int whose value is the number of values in the array

int location;

try {
location = find(ship_setup, ship_setup + moves, submarine_setup)-ship_setup;
}
catch (...) {
cout << "Invalid entry, try again\n";
goto loop;
}


If I understand correctly it should loop it back to the original question instead of giving me a unhandled exception error, yet it does

any help would be greatly appreciated
Last edited on
Is that a call to std::find? std::find does not throw exceptions. You have to make sure that the argument that you pass to std::find is correct.

If it's compiled with Visual C++ in debug mode it could be some kind of non-standard exception mechanism that you can catch in some other way. I don't know how. I don't think it's a good idea to try to catch it because it will not work in release mode or with other compilers.
Last edited on
Topic archived. No new replies allowed.