title: How to reassign an array to another array?
body: <p>Is it possible to reassign an array to another array? Like this:
  This is the function e02:</p>
  
  <pre><code>void e02(){
      int a[] = {15, 9, 8, 4, 3};
      int n = 5;
      int x = 5;
  
      fn02(a, n, x);
  
      cout &lt;&lt; endl;
  
      for(int i = 0; i &lt; n; i++){
          cout &lt;&lt; a[i] &lt;&lt; " ";
      }
  }
  </code></pre>
  
  <p>And this is the function fn02:</p>
  
  <pre><code>void fn02(int* a, int &amp;n, int x){
      n += 1;
  
      int* b = new int[n];
  
      int j = 0;
  
      bool put = false;
  
      for(int i = 0; i &lt; n; i++){
          if(x &gt; a[i] &amp;&amp; put == false){
              b[j] = x;
              j++;
              a--;
              put = true;
          } else{
              b[j] = a[i];
              j++;
          } //else
      } //i loop
  
      a = b;
  }
  </code></pre>
  
  <p>This is supposed to put the variable n into the array but the array still needs to be descending. If I just assign a = b like this then I get the output 15, 9, 8, 4, 3, 5 with 5 being a garbage value. So my question is: Is there a way to reassign an array to a different array like here?
  If I use a pointer like</p>
  
  <pre><code>int* &amp;p1;
  </code></pre>
  
  <p>and then put it in the function I get what I want but the function has to have those parameters and has to be void</p>