   Passing SDL_Surface* to function problem
  I am writing another game and trying to change bits and pieces of previous code as I go along to (hopefully) make it all better. However, in the early stages I have run into a problem.I pass a SDL_Surface* to a function to initialise it using SDL_SetVideoMode. No errors are returned from this function, meaning that inside the function, the SDL_Surface* has been initialsed correctly, however when I try and use the SDL_Surface* in the main program, the program behaves as if the Surface hasn't been initialised. I checked this by moving the SDL_SetVideoMode out of the function and the program runs fine. Any ideas?here is my code:Main:int main(int argc, char* args[]){//SDL Surface to act as screenSDL_Surface* screen = NULL;//Initialise if(init("Snooker", screen) == false){return 1;}//Options///////////////////use enum??bool quit = false;bool fullscreen = false;bool mute = false;if(SDL_FillRect(screen, &screen->clip_rect, SDL_MapRGB(screen->format, 0xFF, 0xFF, 0xFF)) == -1){return 2;}SDL_Flip(screen);SDL_Delay(2000);//Free screen surfaceSDL_FreeSurface(screen);//Close SDL etc.clean_up();return 0;}[\source]init()bool init(std::string caption, SDL_Surface* screen){//Initialise SDLif(SDL_Init(SDL_INIT_EVERYTHING) == -1){return false;}//Initialise SDL TTFif(TTF_Init() == -1){return false;}//Initialise SDL_Mixerif(Mix_OpenAudio(22050, MIX_DEFAULT_FORMAT, 2, 800) == -1){return false;}//Set up the screenscreen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, SDL_SWSURFACE);//If there was an error setting up the screenif(screen == NULL){return false;}//Set the window captionSDL_WM_SetCaption(caption.c_str(), NULL);//If everything initialised finereturn true;}[\source]
  When you pass an argument by value any changes to that argument will happen to the copy, not the original value. In this case you should use a SDL_Surface *& for the argument type rather than an SDL_Surface *.   ;  Oh right, I figured it was something simple I was missing, thanks a lot Si, I hadn't even realised that that combination was legal! :-S   