title: BubbleSort not working
body: <p>It doesn't prints me out the array the second time.</p>
  
  <p>It works if I remove the call to bubbleSort( ... ).</p>
  
  <p>Can't understand why...This type of behaviour is never happened, why would the executor jump the second call to printArray( ... )?</p>
  
  <p>Any suggestions?</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cstdlib&gt;
  using namespace std;
  
  // STRUCT
  struct Array
  {
      int * data;
      unsigned int size;
  };
  
  // PROTYPES
  void printArray( Array &amp; );
  void bubbleSort( Array &amp; );
  
  // MAIN
  int main(int argc, char **argv)
  {
      Array array;
  
      array.size = 10;
      array.data = new int [ array.size ];
  
      for ( unsigned int i = 0; i &lt; array.size; ++i )
          array.data[ i ] = rand() % 10;
  
      printArray( array );
      bubbleSort( array );
      printArray( array );
  
  
      return 0;
  }
  
  void printArray( Array &amp; array )
  {
      for ( unsigned int i = 0; i &lt; array.size; ++i )
          cout &lt;&lt; array.data[ i ] &lt;&lt; ' ';
  
      cout &lt;&lt; endl;
  }
  
  void swap( int &amp; m, int &amp; n )
  {
      int temp = m;
      m = n;
      n = temp;
  }
  
  void bubbleSort( Array &amp; a )
  {
      for ( unsigned int i = 0; i &lt; a.size - 1; ++i )
          for ( unsigned int j = a.size - 1; j &gt;= i; --j )
              if ( a.data[ j-1 ] &gt; a.data[ j ] )
                  swap( a.data[ j-1 ], a.data[ j ] );
  
  }
  </code></pre>