   Displaying text
  Ive recently started trying SDL and have started making my first game. I've written a few "helper functions" but after adding this one:void DisplayText(std::string text,int x,int y, int size,int fR, int fG, int fB,SDL_Surface* target){    TTF_Font* font = TTF_OpenFont("arial.ttf",size);    SDL_Color foreground = {fR,fG,fB};    SDL_Surface* temp = TTF_RenderText_Solid(font, text.c_str(), foreground);    apply_surface(x,y,temp,target); //This is another helper function    SDL_FreeSurface(temp);    TTF_CloseFont(font);}Im getting a segmentation fault, It was working fine until this was added.Any ideas?ThanksCatkill   
  Maybe try checking if font is NULL after your call to OpenFont? Could be not finding your arial.ttf?   ;  When exactly does your program crash? What does your debugger say? The documentation notes that if you pass a null-pointer to TTF_RenderText_Solid for it's font argument, you will get a segfault, so that's likely the problem here. Where is this 'arial.ttf' file located? What folder are you running the executable from?As for the code itself, this function loads a font, creates a surface and then removes that surface, every time you call it. That's not efficient. You'll only want to load that font once, and you'll only want to recreate that surface when you're drawing a different string. In other words, you'll want to remember some things across multiple calls. That makes a function a poor choice - a class would be more suitable. Just thought I'd mention it. ;)   