title: How to add element to C++ array?
body: <p>I want to add an int into an array, but the problem is that I don't know what the index is now.</p>
  
  <pre><code>int[] arr = new int[15];
  arr[0] = 1;
  arr[1] = 2;
  arr[2] = 3;
  arr[3] = 4;
  arr[4] = 5;
  </code></pre>
  
  <p>That code works because I know what index I am assigning to, but what if I don't know the index...</p>
  
  <p>In PHP, I can just do <code>arr[]=22;</code>, which will automatically add 22 to the next empty index of the array. But in C++ I can't do that, it gives me a compiler error. What do you guys suggest?</p>