SDL always stops runnning

Every time I run the below program, it always 'stops responding' in a few seconds, or if I click it. Which ever comes first. It does what it is supposed to do (display a dot in the corner). It returns -805306369 (0xCFFFFFFF), but not in the build log; it returns this in console. Why is it freezing? How do I fix this?
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
27
28
29
  #include <SDL/SDL.h>

const int SCREEN_WIDTH  = 640;
const int SCREEN_HEIGHT = 480;
const int SCREEN_DEPTH  =  32;

int main(int argc, char *argv[]) {
     SDL_Surface *screen;
     Uint8       *p;
     int         x = 10; //x coordinate of our pixel
     int         y = 20; //y coordinate of our pixel

     /* Initialize SDL */
     SDL_Init(SDL_INIT_VIDEO);

     /* Initialize the screen / window */
     screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_DEPTH, SDL_SWSURFACE);

     /* Make p point to the place we want to draw the pixel */
     p = (Uint8 *)screen->pixels + y * screen->pitch + x * screen->format->BytesPerPixel;

     /* Draw the pixel! */
     *p=0xff;

     /* update the screen (aka double buffering) */
     SDL_Flip(screen);
     while(true);
}
while(true);

Don't do this.
Try some of the lazy foo tutorials they are very easy to follow
Topic archived. No new replies allowed.