title: Works in Debugger mode but not in final release....WHY?
body: <p>...iam new here and i have a problem that my code logic seems error free (and it does) and when i run it in debugger mode (using microsoft visual express C++) everything work as it should  by monitoring the variables and its changes however when i run it in release mode its strange that nothing work...or change</p>
  
  <p>what iam trying to do is moving a sprite in a black window (800x600) increasing its X co-ordinate by 1 till it reaches the end of the screen which is (spriteX +24 >798) (24 is the width of the bounding box of the sprite) then when that happens it moves to the other end of the screen then it stops....</p>
  
  <p>the sprite spawn randomly at any point in screen then it moves to right then to left then stops and that what happens in debugger mode ... but in release mode it always spawn in the left edge of screen and not even move to the right or left it just stay there......</p>
  
  <p>here is the code of the sprite moving </p>
  
  <pre><code>   void Game::PooMove()
  {
      /*for (int index = 0; index &lt; npoo; index++)*/
      bool iamfree = true;
      bool iamfree2 = false;
      while (iamfree)
      {
          poox[1]++;
  
          if (poox[1] + 24 &gt; 799)
          {
              iamfree = false;
              iamfree2 = true;
          }
      }
      while (iamfree2)
      {
          poox[1]--;
          if (poox[1] &lt; 1)
          {
              iamfree2 = false;
          }
      }
  }
  </code></pre>
  
  <p>and thats the code for random spawn of the sprite</p>
  
  <pre><code>srand((unsigned int)time(NULL));
      for (int index = 0; index &lt; npoo; index++)
      {
          poox[index] = rand() % (800 - 24);
          pooy[index] = rand() % (600 - 24);
          pooIsEaten[index] = false;
      }
  </code></pre>
  
  <p>considering that its part of a bigger program everything works fine but my problem is in those condition that don't work expect in the debugger only and iam curious to know the solution and why this happens 
  *i can upload the full code/file if that will make things clearer *</p>
  
  <p>here is the drawing code and its calling </p>
  
  <pre><code>void Game::ComposeFrame()
  {
      for (int index = 0; index &lt; npoo; index++)
      {
          if (!(pooIsEaten[index]))
          Drawpoo(poox[index], pooy[index]);
      }
  }
  void Game::Go()
  {   
      UpDateFace();
      UpDatePoo();
      UpDateDot();
      gfx.BeginFrame();
      ComposeFrame();
      PooMove();
      gfx.EndFrame();
  }
  </code></pre>
  
  <p>go function is what calls everything and some are being called in some specific functions like compose frame</p>
  
  <p>thats how drawpoo function work hope the post don't get shut down due to this code</p>
  
  <pre><code>void Game::Drawpoo(int x,int y)
  {
      gfx.PutPixel(14 + x, 0 + y, 138, 77, 0);
      gfx.PutPixel(7 + x, 1 + y, 138, 77, 0);
      gfx.PutPixel(13 + x, 1 + y, 138, 77, 0);
      gfx.PutPixel(20 + x, 1 + y, 138, 77, 0);
      gfx.PutPixel(6 + x, 2 + y, 138, 77, 0);
      gfx.PutPixel(13 + x, 2 + y, 138, 77, 0);
      gfx.PutPixel(20 + x, 2 + y, 138, 77, 0);
      gfx.PutPixel(6 + x, 3 + y, 138, 77, 0);
      gfx.PutPixel(6 + x, 4 + y, 138, 77, 0);
      gfx.PutPixel(14 + x, 4 + y, 138, 77, 0);
      gfx.PutPixel(21 + x, 4 + y, 138, 77, 0);
      gfx.PutPixel(7 + x, 5 + y, 138, 77, 0);
      gfx.PutPixel(13 + x, 5 + y, 138, 77, 0);
      gfx.PutPixel(21 + x, 5 + y, 138, 77, 0);
      gfx.PutPixel(7 + x, 6 + y, 138, 77, 0);
      gfx.PutPixel(20 + x, 6 + y, 138, 77, 0);
      gfx.PutPixel(6 + x, 7 + y, 138, 77, 0);
      gfx.PutPixel(14 + x, 7 + y, 51, 28, 0);
      gfx.PutPixel(15 + x, 7 + y, 51, 28, 0);
      gfx.PutPixel(20 + x, 7 + y, 138, 77, 0);
      gfx.PutPixel(12 + x, 8 + y, 51, 28, 0);
      gfx.PutPixel(13 + x, 8 + y, 51, 28, 0);
      gfx.PutPixel(14 + x, 8 + y, 51, 28, 0);
      gfx.PutPixel(7 + x, 9 + y, 138, 77, 0);
      gfx.PutPixel(11 + x, 9 + y, 51, 28, 0);
      gfx.PutPixel(12 + x, 9 + y, 102, 57, 0);
      gfx.PutPixel(13 + x, 9 + y, 138, 77, 0);
      gfx.PutPixel(14 + x, 9 + y, 138, 77, 0);
      gfx.PutPixel(15 + x, 9 + y, 51, 28, 0);
      gfx.PutPixel(21 + x, 9 + y, 138, 77, 0);
      gfx.PutPixel(10 + x, 10 + y, 51, 28, 0);
      gfx.PutPixel(11 + x, 10 + y, 51, 28, 0);
      gfx.PutPixel(12 + x, 10 + y, 102, 57, 0);
      gfx.PutPixel(13 + x, 10 + y, 138, 77, 0);
      gfx.PutPixel(14 + x, 10 + y, 138, 77, 0);
      gfx.PutPixel(15 + x, 10 + y, 51, 28, 0);
      gfx.PutPixel(20 + x, 10 + y, 138, 77, 0);
      gfx.PutPixel(9 + x, 11 + y, 51, 28, 0);
      gfx.PutPixel(10 + x, 11 + y, 138, 77, 0);
      gfx.PutPixel(11 + x, 11 + y, 138, 77, 0);
      gfx.PutPixel(12 + x, 11 + y, 51, 28, 0);
      gfx.PutPixel(13 + x, 11 + y, 51, 28, 0);
      gfx.PutPixel(14 + x, 11 + y, 51, 28, 0);
      gfx.PutPixel(15 + x, 11 + y, 51, 28, 0);
      gfx.PutPixel(16 + x, 11 + y, 51, 28, 0);
      gfx.PutPixel(9 + x, 12 + y, 51, 28, 0);
      gfx.PutPixel(10 + x, 12 + y, 138, 77, 0);
      gfx.PutPixel(11 + x, 12 + y, 138, 77, 0);
      gfx.PutPixel(12 + x, 12 + y, 111, 62, 0);
      gfx.PutPixel(13 + x, 12 + y, 102, 57, 0);
      gfx.PutPixel(14 + x, 12 + y, 102, 57, 0);
      gfx.PutPixel(15 + x, 12 + y, 102, 57, 0);
      gfx.PutPixel(16 + x, 12 + y, 51, 28, 0);
      gfx.PutPixel(9 + x, 13 + y, 51, 28, 0);
      gfx.PutPixel(10 + x, 13 + y, 109, 61, 0);
      gfx.PutPixel(11 + x, 13 + y, 138, 77, 0);
      gfx.PutPixel(12 + x, 13 + y, 138, 77, 0);
      gfx.PutPixel(13 + x, 13 + y, 138, 77, 0);
      gfx.PutPixel(14 + x, 13 + y, 138, 77, 0);
      gfx.PutPixel(15 + x, 13 + y, 138, 77, 0);
      gfx.PutPixel(16 + x, 13 + y, 51, 28, 0);
      gfx.PutPixel(5 + x, 14 + y, 51, 28, 0);
      gfx.PutPixel(7 + x, 14 + y, 51, 28, 0);
      gfx.PutPixel(8 + x, 14 + y, 51, 28, 0);
      gfx.PutPixel(9 + x, 14 + y, 51, 28, 0);
      gfx.PutPixel(10 + x, 14 + y, 51, 28, 0);
      gfx.PutPixel(11 + x, 14 + y, 138, 77, 0);
      gfx.PutPixel(12 + x, 14 + y, 138, 77, 0);
      gfx.PutPixel(13 + x, 14 + y, 138, 77, 0);
      gfx.PutPixel(14 + x, 14 + y, 138, 77, 0);
      gfx.PutPixel(15 + x, 14 + y, 138, 77, 0);
      gfx.PutPixel(16 + x, 14 + y, 51, 28, 0);
      gfx.PutPixel(4 + x, 15 + y, 51, 28, 0);
      gfx.PutPixel(5 + x, 15 + y, 138, 77, 0);
      gfx.PutPixel(6 + x, 15 + y, 51, 28, 0);
      gfx.PutPixel(7 + x, 15 + y, 116, 65, 0);
      gfx.PutPixel(8 + x, 15 + y, 138, 77, 0);
      gfx.PutPixel(9 + x, 15 + y, 138, 77, 0);
      gfx.PutPixel(10 + x, 15 + y, 138, 77, 0);
      gfx.PutPixel(11 + x, 15 + y, 51, 28, 0);
      gfx.PutPixel(12 + x, 15 + y, 51, 28, 0);
      gfx.PutPixel(13 + x, 15 + y, 51, 28, 0);
      gfx.PutPixel(14 + x, 15 + y, 51, 28, 0);
      gfx.PutPixel(15 + x, 15 + y, 51, 28, 0);
      gfx.PutPixel(16 + x, 15 + y, 51, 28, 0);
      gfx.PutPixel(17 + x, 15 + y, 51, 28, 0);
      gfx.PutPixel(18 + x, 15 + y, 51, 28, 0);
      gfx.PutPixel(1 + x, 16 + y, 51, 28, 0);
      gfx.PutPixel(2 + x, 16 + y, 51, 28, 0);
      gfx.PutPixel(3 + x, 16 + y, 51, 28, 0);
      gfx.PutPixel(4 + x, 16 + y, 51, 28, 0);
      gfx.PutPixel(5 + x, 16 + y, 138, 77, 0);
      gfx.PutPixel(6 + x, 16 + y, 51, 28, 0);
      gfx.PutPixel(7 + x, 16 + y, 116, 65, 0);
      gfx.PutPixel(8 + x, 16 + y, 138, 77, 0);
      gfx.PutPixel(9 + x, 16 + y, 138, 77, 0);
      gfx.PutPixel(10 + x, 16 + y, 138, 77, 0);
      gfx.PutPixel(11 + x, 16 + y, 138, 77, 0);
      gfx.PutPixel(12 + x, 16 + y, 138, 77, 0);
      gfx.PutPixel(13 + x, 16 + y, 109, 61, 0);
      gfx.PutPixel(14 + x, 16 + y, 51, 28, 0);
      gfx.PutPixel(15 + x, 16 + y, 138, 77, 0);
      gfx.PutPixel(16 + x, 16 + y, 138, 77, 0);
      gfx.PutPixel(17 + x, 16 + y, 138, 77, 0);
      gfx.PutPixel(18 + x, 16 + y, 123, 69, 0);
      gfx.PutPixel(19 + x, 16 + y, 51, 28, 0);
      gfx.PutPixel(0 + x, 17 + y, 51, 28, 0);
      gfx.PutPixel(1 + x, 17 + y, 87, 49, 0);
      gfx.PutPixel(2 + x, 17 + y, 87, 49, 0);
      gfx.PutPixel(3 + x, 17 + y, 87, 49, 0);
      gfx.PutPixel(4 + x, 17 + y, 87, 49, 0);
      gfx.PutPixel(5 + x, 17 + y, 51, 28, 0);
      gfx.PutPixel(6 + x, 17 + y, 51, 28, 0);
      gfx.PutPixel(7 + x, 17 + y, 43, 24, 0);
      gfx.PutPixel(8 + x, 17 + y, 51, 28, 0);
      gfx.PutPixel(9 + x, 17 + y, 51, 28, 0);
      gfx.PutPixel(10 + x, 17 + y, 51, 28, 0);
      gfx.PutPixel(11 + x, 17 + y, 51, 28, 0);
      gfx.PutPixel(12 + x, 17 + y, 51, 28, 0);
      gfx.PutPixel(13 + x, 17 + y, 40, 22, 0);
      gfx.PutPixel(14 + x, 17 + y, 51, 28, 0);
      gfx.PutPixel(15 + x, 17 + y, 138, 77, 0);
      gfx.PutPixel(16 + x, 17 + y, 138, 77, 0);
      gfx.PutPixel(17 + x, 17 + y, 138, 77, 0);
      gfx.PutPixel(18 + x, 17 + y, 123, 69, 0);
      gfx.PutPixel(19 + x, 17 + y, 51, 28, 0);
      gfx.PutPixel(0 + x, 18 + y, 51, 28, 0);
      gfx.PutPixel(1 + x, 18 + y, 138, 77, 0);
      gfx.PutPixel(2 + x, 18 + y, 138, 77, 0);
      gfx.PutPixel(3 + x, 18 + y, 138, 77, 0);
      gfx.PutPixel(4 + x, 18 + y, 138, 77, 0);
      gfx.PutPixel(5 + x, 18 + y, 51, 28, 0);
      gfx.PutPixel(6 + x, 18 + y, 51, 28, 0);
      gfx.PutPixel(7 + x, 18 + y, 51, 28, 0);
      gfx.PutPixel(8 + x, 18 + y, 51, 28, 0);
      gfx.PutPixel(9 + x, 18 + y, 51, 28, 0);
      gfx.PutPixel(10 + x, 18 + y, 51, 28, 0);
      gfx.PutPixel(11 + x, 18 + y, 51, 28, 0);
      gfx.PutPixel(12 + x, 18 + y, 51, 28, 0);
      gfx.PutPixel(13 + x, 18 + y, 51, 28, 0);
      gfx.PutPixel(14 + x, 18 + y, 51, 28, 0);
      gfx.PutPixel(15 + x, 18 + y, 138, 77, 0);
      gfx.PutPixel(16 + x, 18 + y, 138, 77, 0);
      gfx.PutPixel(17 + x, 18 + y, 138, 77, 0);
      gfx.PutPixel(18 + x, 18 + y, 123, 69, 0);
      gfx.PutPixel(19 + x, 18 + y, 51, 28, 0);
      gfx.PutPixel(20 + x, 18 + y, 51, 28, 0);
      gfx.PutPixel(21 + x, 18 + y, 51, 28, 0);
      gfx.PutPixel(22 + x, 18 + y, 51, 28, 0);
      gfx.PutPixel(0 + x, 19 + y, 51, 28, 0);
      gfx.PutPixel(1 + x, 19 + y, 138, 77, 0);
      gfx.PutPixel(2 + x, 19 + y, 138, 77, 0);
      gfx.PutPixel(3 + x, 19 + y, 138, 77, 0);
      gfx.PutPixel(4 + x, 19 + y, 138, 77, 0);
      gfx.PutPixel(5 + x, 19 + y, 51, 28, 0);
      gfx.PutPixel(6 + x, 19 + y, 138, 77, 0);
      gfx.PutPixel(7 + x, 19 + y, 138, 77, 0);
      gfx.PutPixel(8 + x, 19 + y, 138, 77, 0);
      gfx.PutPixel(9 + x, 19 + y, 138, 77, 0);
      gfx.PutPixel(10 + x, 19 + y, 138, 77, 0);
      gfx.PutPixel(11 + x, 19 + y, 138, 77, 0);
      gfx.PutPixel(12 + x, 19 + y, 138, 77, 0);
      gfx.PutPixel(13 + x, 19 + y, 138, 77, 0);
      gfx.PutPixel(14 + x, 19 + y, 138, 77, 0);
      gfx.PutPixel(15 + x, 19 + y, 138, 77, 0);
      gfx.PutPixel(16 + x, 19 + y, 138, 77, 0);
      gfx.PutPixel(17 + x, 19 + y, 138, 77, 0);
      gfx.PutPixel(18 + x, 19 + y, 123, 69, 0);
      gfx.PutPixel(19 + x, 19 + y, 51, 28, 0);
      gfx.PutPixel(20 + x, 19 + y, 138, 77, 0);
      gfx.PutPixel(21 + x, 19 + y, 138, 77, 0);
      gfx.PutPixel(22 + x, 19 + y, 65, 36, 0);
      gfx.PutPixel(23 + x, 19 + y, 51, 28, 0);
      gfx.PutPixel(1 + x, 20 + y, 51, 28, 0);
      gfx.PutPixel(2 + x, 20 + y, 51, 28, 0);
      gfx.PutPixel(3 + x, 20 + y, 51, 28, 0);
      gfx.PutPixel(4 + x, 20 + y, 51, 28, 0);
      gfx.PutPixel(5 + x, 20 + y, 51, 28, 0);
      gfx.PutPixel(6 + x, 20 + y, 138, 77, 0);
      gfx.PutPixel(7 + x, 20 + y, 138, 77, 0);
      gfx.PutPixel(8 + x, 20 + y, 138, 77, 0);
      gfx.PutPixel(9 + x, 20 + y, 138, 77, 0);
      gfx.PutPixel(10 + x, 20 + y, 138, 77, 0);
      gfx.PutPixel(11 + x, 20 + y, 138, 77, 0);
      gfx.PutPixel(12 + x, 20 + y, 138, 77, 0);
      gfx.PutPixel(13 + x, 20 + y, 138, 77, 0);
      gfx.PutPixel(14 + x, 20 + y, 138, 77, 0);
      gfx.PutPixel(15 + x, 20 + y, 138, 77, 0);
      gfx.PutPixel(16 + x, 20 + y, 138, 77, 0);
      gfx.PutPixel(17 + x, 20 + y, 138, 77, 0);
      gfx.PutPixel(18 + x, 20 + y, 123, 69, 0);
      gfx.PutPixel(19 + x, 20 + y, 51, 28, 0);
      gfx.PutPixel(20 + x, 20 + y, 138, 77, 0);
      gfx.PutPixel(21 + x, 20 + y, 138, 77, 0);
      gfx.PutPixel(22 + x, 20 + y, 65, 36, 0);
      gfx.PutPixel(23 + x, 20 + y, 51, 28, 0);
      gfx.PutPixel(0 + x, 21 + y, 51, 28, 0);
      gfx.PutPixel(1 + x, 21 + y, 138, 77, 0);
      gfx.PutPixel(2 + x, 21 + y, 138, 77, 0);
      gfx.PutPixel(3 + x, 21 + y, 138, 77, 0);
      gfx.PutPixel(4 + x, 21 + y, 138, 77, 0);
      gfx.PutPixel(5 + x, 21 + y, 138, 77, 0);
      gfx.PutPixel(6 + x, 21 + y, 51, 28, 0);
      gfx.PutPixel(7 + x, 21 + y, 51, 28, 0);
      gfx.PutPixel(8 + x, 21 + y, 51, 28, 0);
      gfx.PutPixel(9 + x, 21 + y, 51, 28, 0);
      gfx.PutPixel(10 + x, 21 + y, 51, 28, 0);
      gfx.PutPixel(11 + x, 21 + y, 51, 28, 0);
      gfx.PutPixel(12 + x, 21 + y, 51, 28, 0);
      gfx.PutPixel(13 + x, 21 + y, 51, 28, 0);
      gfx.PutPixel(14 + x, 21 + y, 51, 28, 0);
      gfx.PutPixel(15 + x, 21 + y, 51, 28, 0);
      gfx.PutPixel(16 + x, 21 + y, 51, 28, 0);
      gfx.PutPixel(17 + x, 21 + y, 51, 28, 0);
      gfx.PutPixel(18 + x, 21 + y, 51, 28, 0);
      gfx.PutPixel(20 + x, 21 + y, 51, 28, 0);
      gfx.PutPixel(21 + x, 21 + y, 51, 28, 0);
      gfx.PutPixel(22 + x, 21 + y, 51, 28, 0);
      gfx.PutPixel(0 + x, 22 + y, 51, 28, 0);
      gfx.PutPixel(1 + x, 22 + y, 65, 36, 0);
      gfx.PutPixel(2 + x, 22 + y, 65, 36, 0);
      gfx.PutPixel(3 + x, 22 + y, 65, 36, 0);
      gfx.PutPixel(4 + x, 22 + y, 65, 36, 0);
      gfx.PutPixel(5 + x, 22 + y, 65, 36, 0);
      gfx.PutPixel(6 + x, 22 + y, 51, 28, 0);
      gfx.PutPixel(1 + x, 23 + y, 51, 28, 0);
      gfx.PutPixel(2 + x, 23 + y, 51, 28, 0);
      gfx.PutPixel(3 + x, 23 + y, 51, 28, 0);
      gfx.PutPixel(4 + x, 23 + y, 51, 28, 0);
      gfx.PutPixel(5 + x, 23 + y, 51, 28, 0);
      gfx.PutPixel(6 + x, 23 + y, 51, 28, 0);
  }
  </code></pre>
  
  <p>and how poox and pooy are declared </p>
  
  <pre><code>#define NPOO 3
  class Game{
  /*many functions and variables*/
  int poox[NPOO];
  int pooy[NPOO];
  }
  </code></pre>