title: How to copy array in c++
body: <p>I am trying to capture array instances in a function doSomething as Arrays in c++ are passed by reference  this is not possible .Is there any workaround to solve this problem!</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  int *A[10][10];
  
  void doSomething(int ar[],int n){
      A[1][2] = ar;
      for (int i=0;i&lt;n;i++){
          ar[i]+=1;
      }
      A[2][3] = ar;
  }
  
  
  int main(){
      int ar[] = {1,2,3,4,5};
      int n = 5;
      doSomething(ar,n);
      for (int i=0;i&lt;n;i++){
          cout&lt;&lt;A[1][2][i]&lt;&lt;" "; // this should be 1 2 3 4 5 but output is 2 3 4 5 6 
      }
      cout&lt;&lt;endl;
      for (int i=0;i&lt;n;i++){
          cout&lt;&lt;A[2][3][i]&lt;&lt;" ";
      }
  
  }
  </code></pre>
  
  <p>here first cout in main will print 2 3 4 5 6 but here I want output as 1 2 3 4 5</p>