-
unhandled exception?
Hello, what this function is suppose to do is wait for the user to either click button one, button two, or ex out the program. Instead, i get this error:
Code:
Unhandled exception at 0x00973faa in TicTacToe v2.0.exe: 0xC0000005:
Access violation reading location 0xfeeefeee.
Here is the code that triggers this error:
Code:
void Title::HandleEvents()
{
SDL_Event event;
//While there's events to handle
while( SDL_PollEvent( &event ) )
{
if( event.type == SDL_MOUSEBUTTONDOWN )
{
if( event.button.button == SDL_BUTTON_LEFT )
{
int x = event.button.x;
int y = event.button.y;
if( (x > 200 && x < 300) && (y > 160 && y < 200 ) )
{
SetNextState( STATE_TITLE, STATE_1PLAYER );
}
if( (x > 330 && x < 430) && (y > 160 && y < 200 ) )
{
SetNextState( STATE_TITLE, STATE_2PLAYER );
}
}
}
if( event.type == SDL_QUIT )
{
//Quit the program
SetNextState( STATE_TITLE, STATE_EXIT );
}
}
}
-
Re: unhandled exception?
Have you run it in the debugger to see what line of your code is causing this?
Viggy
-
Re: unhandled exception?
@viggy:
The problem is inside of a while loop that waits for an event, so when i debug look like i cant see what the exact line of code.
-
Re: unhandled exception?
You should have a stack trace that shows what call inside your code ultimately leads to the exception. Then, you look to see that all your variables are what you expect them to be.
Viggy
-
Re: unhandled exception?
@viggy: not really sure how to do that but here is the project so you can take a look at it.
http://www.mediafire.com/?722s9rsjneo51bw
-
Re: unhandled exception?
In visual studio 2005 (and probably later ones too) there is a little icon that looks like a window with three little windows on top of it. Hovering your mouse over it shows the label "Call Stack". Clicking this at a breakpoint or error will bring up a window at the bottom that shows the whole history of the program up until that point. You can double-click each line to take you to the section of code, and hovering your mouse over any variable should tell you what it equals.
Do this, and you will find the source of your problem.
-
Re: unhandled exception?
@ quantumcat:
I clicked what you said but all that happend was a box came up with a graph of weird letters and stuff. If i doubled click a line it just brought up some weird .cpp's.
-
Re: unhandled exception?
Have you tried setting a break point on the first line in SetNextState and single step from that point?