1 2
|
int array1[MAX];
int array2[MAX];
|
When you first declare an array, it has uninitialized values. If you want to set uninitialized values to zero, initialize each array by doing
1 2
|
int array1[MAX] = {}; // initializes each element to its default value, 0.
int array2[MAX] = {};
|
Then, when you fill in your array, say, with {1, 2, 3, 4, 5}, the rest of the numbers will be 0.
{1, 2, 3, 4, 5, 0, 0, 0, 0, ...}.
1 2 3 4 5
|
int temp = 0;
while (input[size] != 0) {
temp++;
}
size = temp;
|
Note that this won't be able to detect when 0 is actual valid data; you are treating 0 as a sentinel value in this manner.
Also, note you're not really supposed to call the destructors manually.