I am having issues with the dynamic arrays. I am taking one array and creating a new one with double the size. I want to keep the original elements of the arrays and fill the remaining with -1. I am able to double the array but I cannot figure out how to fill the rest with -1 :(
#include <iostream>
int main ()
{
int old_size = 10;
int new_size = old_size * 2;
int* oldArr = newint[old_size];
int* newArr = newint[new_size];
// init old array
for (int i = 0; i < old_size; i++)
{
oldArr[i] = i;
}
// init new Array
for (int i = 0; i < new_size; i++)
{
newArr[i] = -1;
}
// copy from old array to new array
for (int i = 0; i < old_size; i++)
{
newArr[i] = oldArr[i];
}
// display the new array
for (int i = 0; i < new_size; i++)
{
std::cout << newArr[i] << " ";
}
std::cout << "\n\n";
// clean up
delete [] oldArr;
delete [] newArr;
system ("pause");
return 0;
}