title: Remove all occurrences of a number in an array in C++
body: <p>Supposed we passed in the array {1, 2, 3, 1, 2, 3, 1}, and we wanted to
      remove all occurrences of the number 3.  The resulting array would be
      {1, 2, 1, 2, 1}, and the return value would be 5, because there are now
      only 5 items in the array.
  <strong>This function is wrong. I don't know how to remove the occurrences. I know my index holds the positions of the occurrences. So i need to delete those positions from my array. HELP!!</strong>
  I can only use arrays, i cannot use vectors or pointers.</p>
  
  <pre><code>void test() {
  
      int data[] = { 2, 1, 3, 2, 5, 2, 7, 8, 4, 9 };
      int length = 10;
      int x = 2;
      int index = 0;
      int counter =0;
  
  
      int tempIndex = 0;
      int finalLength = 0;
      for (int i = 0; i &lt; length; i++)
      {
          if (x != data[i]) {
  
              tempIndex = i;
              counter++;
              cout &lt;&lt; "Array: " &lt;&lt; tempIndex &lt;&lt; endl;
          }
      }
      cout &lt;&lt; "Size: " &lt;&lt; counter &lt;&lt; endl;
  }
  </code></pre>