title: SDL - Get native Screen Resolution
body: <p>My code:</p>
  
  <ol>
  <li><p><em>window.cpp</em></p>
  
  <pre><code>Window::Window(int w, int h, const char *title, const char *icon)
  {
      height = h;
      width = w;
  
      if(SDL_Init( SDL_INIT_EVERYTHING ) == 0)
      {
          SDL_WM_SetCaption(title, NULL);
          SDL_WM_SetIcon(SDL_LoadBMP(icon),NULL);
  
          screen = SDL_SetVideoMode(width, height, 32,
                       SDL_SWSURFACE | SDL_RESIZABLE | SDL_DOUBLEBUF);
          if(screen == NULL)
          {
              running = false;
              return;
          }
          fullscreen = false;
      }
      else
          running = false;
          return;
  }
  
  Window::Window()
  {
      const SDL_VideoInfo* info = SDL_GetVideoInfo();
      screenWidth = info-&gt;current_w;
      screenHeight = info-&gt;current_h;
      Window(640, 480, "Flatgu game", "rsc/img/icon.bmp");
  }
  </code></pre></li>
  <li><p><em>window.h</em></p>
  
  <pre><code>class Window
  {
  public:
      Window();
      ~Window();
  
      int getWidth() {return width;}
      int getHeight() {return height;}
      bool isFullscreen() {return fullscreen;}
  
      void toggleFullscreen();
  
  private:
      Window(int w, int h, const char *title, const char *icon);
  
      bool fullscreen, running;
      int height, width, screenWidth, screenHeight;
      SDL_Surface *screen;
  };
  </code></pre></li>
  </ol>
  
  <p>It compiles fine, but then, after compiling, I'm getting this ugly error:
  <img src="https://i.stack.imgur.com/QPv13.png" alt="Some address problem"></p>
  
  <p>What's the reason of my problem? Why do I get so weird numbers?</p>
  
  <p><strong>My aim is to store original screen resolution for further use</strong> (like <em>toggling to fullscreen</em>), and I have to do this before calling <code>SDL_SetVideoMode()</code>. That's why it is in the constructor.</p>