Try catch not working, Exception thrown at 0x00476F1E in game1.exe: 0xC0000005: Access violation reading location 0x00000004

0

Code:

try {
    SDL_SetColorKey(surfaces[folderCnt][surfacesCnt], SDL_TRUE, SDL_MapRGB(surfaces[folderCnt][surfacesCnt]->format, 255, 0, 255));
}
catch (int err) {

}

Error: Exception thrown at 0x00476F1E in game1.exe: 0xC0000005: Access violation reading location 0x00000004.

When surfacesCnt = 10 it throws the error. That is because there is no surface 10. I know that and I want to catch the exception and process the next surface (surfacesCnt = 11).

Why are the try catch statements not catching the error? This would work perfectly in Python and Pascal.

c++
try-catch
asked on Stack Overflow Oct 11, 2020 by Seb0029

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0