I've been given a test for a placement at a programming company and I'm a bit stuck. I've been given some code for a space invaders style game that doesn't quite work. The first issue to solve was that it didn't compile and I fixed those problems without too much difficulty. The next issue is that when you run it, it crashes with an unhandled exception. Specifically it has the error code 0xC0000005: Access violation when reading location 0x3c888889. Since this is a test I would really prefer not to paste any code here as I think that would be cheating. But I'm completely new to exceptions, I've never had to deal with them before and the documentation I've read has gone over my head a little. So far as I understand the problem, its something like a pointer, pointing to something it shouldn't, but that could be totally wrong.
All the info that I have read about exception handling suggests using try and catch blocks. But I have no idea how to implement them or how they help me find what the problem is.
I guess what I'm looking for is a bit of "exceptions of dummies" type help here. Thanks in advance for any help.
hi,
I'm not shore how will someone give you an example without seeing your code cos exception handling is not univerzal.
consider this exception block:
1 2 3 4 5 6 7
try {
if (pointer == "some location")
throw; // end try block and throw exception
}
catch(...) {
//handle it here
}
this is generic and without your code there not much to explain you,
paste your code or read some tutorial about exceptions.
Sorry, I don't know quite how to explain the sort of level I'm at with regards to exceptions. I understand that they are errors that occur at runtime. But with regards to try and catch blocks, I have no idea where in the code they are supposed to go, nor do I know what code should go where your //handle it here comment is.
I thought there might be just some problem with the code's syntax that was causing this error. Are exceptions something that cannot be fixed and just have to be dealt with when they occur?
I've tried reading some tutorials on exceptions but they seem to imply to me that in order to sort out exceptions you need to create so much extra code to just find where the error is. Is it really not as simple as fixing a syntax problem.
@codekiddy Thanks very much for that video (both links were the same) it helped me understand exceptions alot.
Unfortunately it means that I understand enough to know I've been asking the wrong questions! I'm going to open a new post to try and get the new problem I've realised I have sorted.
Thanks also to coder777. You are right, I really don't want to have to think about exceptions!