mingw SDL program compile and build ok but exe not working

I compile my sdl c++ program using mingw2.05 without error. But when I try to run the exe file, it pops up a window with correct caption name and then close at once. What can I do? Any help is appreciated.

I post some of the codes here:

// Attempt to create a 640x480 window with 32bit pixels.
gScreen = SDL_SetVideoMode(640, 480, 32, SDL_SWSURFACE);

//Initialize fonts
fontInit();

// If we fail, return error.
if (gScreen == NULL)
{
fprintf(stderr, "Unable to set up video: %s\n", SDL_GetError());
exit(1);
}

// Set Windows caption to be Finance Quiz Game
SDL_WM_SetCaption( "Finance Quiz Game", NULL );

// prepare main menu, load title image and start button
int notepad=0;
while (main_menu == 1) {
imgui_prepare();

ShowBMP("background_640x480.png",gScreen,0,0);
ShowBMP("title.bmp",gScreen,80,60);
Topic archived. No new replies allowed.