Re: [Dev-C++] Catching illegal pointer access
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Daniel K. O. <dan...@ya...> - 2004-09-19 20:13:19
|
Daniel Monteiro Ferreira wrote: > I'm a DevC++ newbie and I'm still trying to get used to it. I wrote a > test program to see what happens if I try to access the contents of a > null pointer. I wrote the illegal access inside a try/catch block, but > instead of executing the catch block, the program simply shows an > error message and aborts. I set the code generation settings to enable > exception handling, but it didn't work. Can't this kind of error be > treated as an exception? If not, how can I keep my program from > aborting? I would apreciate if anybody helped me. Thanks! Exceptions are used to handle run-time "errors". Accessing an invalid address is solely a programming error. What could you possibly do if at one point in your program you access an invalid address? It means that your algorithm is wrong, and you lost the data you were trying to access. Daniel K. O. |