Hi, I've designed a program that creates an array of a particular size specified by the user. This array is then passed to a function that copies the contents of the array and adds them to a larger array. What is weird and what I can't figure out is why when I make the array of size 2 I get some strange output. If I select an array of any other size, the new array contents (the larger array with the copied values from the original array) is made up of zeros. Can anyone explain why an array of size 2 yields the following output?
Output when 2 is entered for array size:
1 2 3 4 5
Enter the size of the array: 2
Initial Array Size: 2
Initial Array Contents: 22 25
New Array Size: 4
New Array Contents: 22 25 16253272 0
Other Output:
1 2 3 4 5
Enter the size of the array: 3
Initial Array Size: 3
Initial Array Contents: 58 99 42
New Array Size: 6
New Array Contents: 58 99 42 0 0 0
1 2 3 4 5
Enter the size of the array: 4
Initial Array Size: 4
Initial Array Contents: 37 16 30 29
New Array Size: 8
New Array Contents: 37 16 30 29 0 0 0 0