another problem with sdl

i had some problems with an sdl code earlier today and made a post about it. the problem i was having kind of got solved (by me). it turns out i just kind of had a problem with visual stuido and not with the code itself (or i had a problem with the code as well but the problem i posted about was solved) right after that i tried ti compile the code and another window popped up telling me this:

Run-Time Check Failure #3 - The variable 'event' is being used without being initialized.

here is the code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include "SDL.h"

int main( int argc, char* args[] )
{
	SDL_Init ( SDL_INIT_EVERYTHING );
	SDL_WM_SetCaption ("yay!", NULL);

	SDL_Surface *buffer;
	bool fullscreen = false;
	SDL_Event event;

	if (fullscreen == true){
		buffer = SDL_SetVideoMode(640, 480, 32, SDL_SWSURFACE | SDL_FULLSCREEN);
	}
	else{
		SDL_SetVideoMode (640, 480, 32, SDL_SWSURFACE);
	}

	while ( event.type != SDL_QUIT){
		SDL_PollEvent (&event);
		SDL_Flip(buffer);
	}
    
	SDL_Quit;
	return 0;    
}


can anyone tell me what i did wrong?
Last edited on
You need to call "SDL_Poll(...)" before your while loop on Line 19. Otherwise it's value is undefined.
thanks mate :D

it worked perfectly the first time, but then when i tried to run it a 2nd time it froze. any idea as to what causes that?
Does it lock if you try it a third time?

- Make sure no part of the application is still open in the background.

- Close the IDE and reopen your project.

- Make sure none of the files you are trying to compile are locked.

- Reboot your PC?

It's really hard to say what could cause it to lock up. There are just too many possibilities if it's even your program that's causing it.
it sais it cant find or cant open the pdb file. it sais it like 20 times every time i open the program (like for a lot of different pathes) could this be the cause? if so, do you have any idea as to how i can fix it?
Topic archived. No new replies allowed.