title: SDL2 Hello World tutorial closes with error
body: <p>I'm developing in VS2013 on a Windows 8.1 machine. The window flashes briefly on the screen (despite having a 2 second delay in the code).</p>
  
  <p>Here is all the code: </p>
  
  <pre><code>#include &lt;SDL.h&gt;
  #include &lt;iostream&gt;
  
  int main(int argc, char **argv)
  {
  if (SDL_Init(SDL_INIT_EVERYTHING) != 0){
      std::cout &lt;&lt; "SDL_Init Error: " &lt;&lt; SDL_GetError() &lt;&lt; std::endl;
      return 4;
  }
  
  //open a window
  SDL_Window *win = SDL_CreateWindow("Hello World!", 100, 100, 640, 480, SDL_WINDOW_SHOWN);
  if (win == nullptr){
      std::cout &lt;&lt; "SDL_CreateWindow Error: " &lt;&lt; SDL_GetError() &lt;&lt; std::endl;
      return 3;
  }
  
  //renderer
  SDL_Renderer *ren = SDL_CreateRenderer(win, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
  if (ren == nullptr){
      std::cout &lt;&lt; "SDL_CreateRenderer Error: " &lt;&lt; SDL_GetError() &lt;&lt; std::endl;
      return 2;
  }
  
  //load bitmap
  SDL_Surface *bmp = SDL_LoadBMP("helloworld.jpg");
  if (bmp == nullptr){
      std::cout &lt;&lt; "SDL_LoadBMP Error: " &lt;&lt; SDL_GetError() &lt;&lt; std::endl;
      return 6;
  }
  
  SDL_Texture *tex = SDL_CreateTextureFromSurface(ren, bmp);
  SDL_FreeSurface(bmp);
  if (tex == nullptr){
      std::cout &lt;&lt; "SDL_CreateTextureFromSurface Error: " &lt;&lt; SDL_GetError() &lt;&lt; std::endl;
      return 5;
  }
  
  SDL_RenderClear(ren);
  SDL_RenderCopy(ren, tex, NULL, NULL);
  SDL_RenderPresent(ren);
  
  SDL_Delay(2000);
  
  
  return 0;
  }
  </code></pre>
  
  <p>It exits with a code 6. I was thinking it couldn't find the helloworld.jpg file. But, its there. I moved it from location to location hoping I was just an idiot. No luck. Its currently in the same directory as the .exe file.</p>