I copied the following from a back but I'm getting the erros that you see at the bottom of the page.
#include <SDL/SDL.h>
#include <stdio.h>
#include <stdlib.h>
int main()
{
int main()
SDL_Surface *screen;
if(SDL_Init(SDL_INIT_VIDEO) != 0)
{
printf("Unable to initialize SDL: %s\n", SDL_GetError());
return 1;
}
atexit(SDL_Quit);
screen = SDL_Set_VideoMode(640, 480, 16, SDL_FULLSCREEN);
if(screen == NULL)
{
printf("Unable to set video mode: %s\n", SDL_GetError());
return 1;
}
printf("Success!\n");
return 0;
}
Compile line -> gcc initializing-sdl.c -o sdltest \
sdl-config --cflags --libs``
Errors
initializing-sdl.c: In function ‘main’:
initializing-sdl.c:11:9: error: expected declaration specifiers before ‘if’
if(SDL_Init(SDL_INIT_VIDEO) != 0)
^
initializing-sdl.c:17:9: error: expected declaration specifiers before ‘atexit’
atexit(SDL_Quit);
^
initializing-sdl.c:19:9: error: expected declaration specifiers before ‘screen’
screen = SDL_Set_VideoMode(640, 480, 16, SDL_FULLSCREEN);
^
initializing-sdl.c:21:9: error: expected declaration specifiers before ‘if’
if(screen == NULL)
^
initializing-sdl.c:27:9: error: expected declaration specifiers before ‘printf’
printf("Success!\n");
^
initializing-sdl.c:29:9: error: expected declaration specifiers before ‘return’
return 0;
^
initializing-sdl.c:30:1: error: expected declaration specifiers before ‘}’ token
}
^
initializing-sdl.c:9:22: error: declaration for parameter ‘screen’ but no such parameter
SDL_Surface *screen;
^
initializing-sdl.c:30:1: error: expected ‘{’ at end of input
}
^
initializing-sdl.c: In function ‘main’:
initializing-sdl.c:30:1: error: expected declaration or statement at end of input
Again, I got this from my book.