0
Handle system errors that cause C++ crash
I'm used to everything throwing exceptions in Java and being able to wrap things in a try/catch. I'm trying to write a program in C++, part of it involves taking user input via a regex iterator then transfer the values into a string array. When user input is not valid I get a cannot dereference error. I understand why but am not sure how to handle it. I want to be able to loop the user input until valid input is given. Thanks for the help!
2 Antworten
+ 2
We have checks like if(std::cin) and every library has its own exception handling model. You must read in the documentation how to catch errors.
try catch isn't used often in C++ because this language is really concerned about performance.
+ 1
Thanks Timon, I'll have to look closer at the documentation for the library I'm using.