title: Updating a pointer to a c array from a function
body: <p>Say I have a function called <code>array_push</code> in c.</p>
  
  <pre><code>void array_push(int *array_pointer, int array_length, int val) {
      int i;
      int *temp_array = malloc(sizeof(int) * (array_length + 1));
  
      for (i = 0; i &lt; array_length; i++) {
          temp_array[i] = *array_pointer;
          array_pointer++;
      }
  
      temp_array[array_length] = val;
      *array_pointer = temp_array;
  }
  </code></pre>
  
  <p>How can I update the pointer <code>*array_pointer</code> so that it points to <code>temp_array</code> and other parts of my program can use the new array? Allowing me to do something like</p>
  
  <pre><code>int t[2] = {0,2};
  array_push(t, 2);
  /* t should now contain {0,2,3} */ 
  </code></pre>