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!

6th Apr 2018, 11:55 AM
Justin Hinkle
Justin Hinkle - avatar
2 Respuestas
+ 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.
6th Apr 2018, 12:30 PM
Timon Paßlick
+ 1
Thanks Timon, I'll have to look closer at the documentation for the library I'm using.
6th Apr 2018, 12:36 PM
Justin Hinkle
Justin Hinkle - avatar