Copying two array into one larger array?
<p>I have the following question:</p>

<blockquote>
  <p>Write a program with a function named "merge" that copies the data integers of one array into a larger sized array, and then copies the data integers of the second array into the larger array just after the contents of the first array</p>
</blockquote>

<p>There is something wrong with my function </p>

<p>If I entered {1,2} for array 1 and {3,4} for array 2</p>

<p>then the output is 1 2 -57574 -658675<br>
It should be 1 2 3 4 </p>

<pre><code>void merge (int a[], int n, int b[],int m) {

int c[100];
int x=n+m ; //size of merge aray c[] 

for(int i = 0; i &lt; n; i++)
c[i]=a[i];

for(int j = n ; j &lt; x ; j++)
c[j] = b[j];

cout&lt;&lt;endl&lt;&lt;endl;


for(int k = 0; k &lt; x; k++)

cout&lt;&lt;c[k]&lt;&lt;" ";


}
</code></pre>
