View Single Post
Old 07-22-2005, 12:57 PM   #2 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,709
redhead is on a distinguished road
Here is your problem:
Code:
int main(int nNumberofArgs, char* pszArgs[])
{
	if(SDL_Init(SDL_INIT_VIDEO) < 0 ) {
		fprintf(stderr, "Could not initialize SDL: %s\n",
				SDL_GetError());
			return -1;
}
You missed a ending } for your if() statement.
This should be better:
Code:
int main(int nNumberofArgs, char* pszArgs[])
{
	if(SDL_Init(SDL_INIT_VIDEO) < 0 ) {
		fprintf(stderr, "Could not initialize SDL: %s\n",
				SDL_GetError());
			return -1;
             }
      return 0;
}
Altho the ending part of it, dosn't make any sence
Code:
atexit(SDL_Quit);

SDL_Surface* screen;
screen = SDL_SetVideoMode(640, 480, 16, SDL_SWSURFACE|SDL_ANYFORMAT);
if( !screen ) {
	fprintf(stderr, "Couldn't create a surface: %s\n",
			SDL_GetError());
	return -1;
}
is left floating in mid air. You are not allowed to have an if() statement standing alone, it must be encapsulated by some form of function, from where you can activate that code in the simple function call elsewhere in your code. If I were you, I would merge that with the main() function, so entire code would be something like this:
Code:
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <SDL/SDL.h> 
using namespace std;

int main(int nNumberofArgs, char* pszArgs[])
{
    if(SDL_Init(SDL_INIT_VIDEO) < 0 ) {
        fprintf(stderr, "Could not initialize SDL: %s\n",SDL_GetError());
        return -1;
    }
    atexit(SDL_Quit);
    SDL_Surface* screen;
    screen = SDL_SetVideoMode(640, 480, 16, SDL_SWSURFACE|SDL_ANYFORMAT);
    if( !screen ) {
        fprintf(stderr, "Couldn't create a surface: %s\n", SDL_GetError());
        return -1;
    }
    return 0;
}
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote