title: C++ SDL Unhandled exception at 0x6C7DB2AA (SDL2.dll) in "File".exe: 0xC0000005: Access violation reading location 0x00000044
body: <p>Getting in to SDL I stated following the tutorials "StaysCrisp" on DreamInCode. The problem is that when I am trying to use one of the draw methods. I get the Error : </p>
  
  <pre><code>Unhandled exception at 0x6C7DB2AA (SDL2.dll) in Tutorial.exe:
  0xC0000005: Access violation reading location 0x00000044. 
  </code></pre>
  
  <p>The problem is in the Sprite class draw method. So here's the code. Also on a side note I am using the latest version of SDL(2.0.3), and I can tell from the code that StaysCrisp is not.</p>
  
  <pre><code>#include "Sprite.h"
  
  //constructor
  Sprite::Sprite()
  {
  
  }
  
  SDL_Surface*Sprite::Load(char*File)
  {
      SDL_Surface*temp = NULL;
      SDL_Surface*optimized = NULL;
  
      if ((temp = IMG_Load(File)) == NULL)
      {
          return NULL;
      }
  
      optimized = temp;
      SDL_FreeSurface(temp);
  
      return optimized;
  }
  
  bool Sprite::Draw(SDL_Surface*dest, SDL_Surface*src, int x, int y)
  {
      if (dest == NULL || src == NULL)
      {
          return false;
          std::cout &lt;&lt; "Could not draw the entire surface!\n ERROR: SPRITE.CCP";
      }
  
      SDL_Rect destR;
  
      destR.x = x;
      destR.y = y;
  
      SDL_BlitSurface(src, NULL, dest, &amp;destR); //Compiler says the problem is here
  
      return true;
  
  }
  
  bool Sprite::Draw(SDL_Surface*dest, SDL_Surface*src, int x, int y,
      int x2, int y2, int width, int height)
  {
      if (dest == NULL || src == NULL)
      {
          std::cout &lt;&lt; "Could not draw sprite. SPRITE.CCP \n";
          return false;
      }
  
      SDL_Rect destR;
  
      destR.x = x;
      destR.y = y;
  
  
      SDL_Rect srcR;
  
      srcR.x = x2;
      srcR.y = y2;
      srcR.w = width;
      srcR.h = height;
  
      SDL_BlitSurface(src, &amp;srcR, dest, &amp;destR); //Compiler says the problem is here
  
      return true;
  
  }
  </code></pre>