The error message you are getting now is a clear indication that you're writing past the bounds of an object (esp. an array) with automatic storage duration.
numbers is a fixed-size array with automatic storage duration. How many elements does it have? How large is it?
This program works but how come this works? I think this should be an error. I thought I was supposed to delete the original array, then copy the original array to the new array, finally add additional numbers
$ ./foo
Add number? (Y/n): y
Enter how many number to enter:10
Created array of 10 numbers
1
2
3
4
5
6
7
8
9
10
Add number? (Y/n): y
Enter how many number to enter:3
1
2
3
Add number? (Y/n): n
1
2
3
4
5
6
7
8
9
10
1
2
3
1
2
3
4
5
6
7
8
9
10
83
0
0
Where the heck does 83 come from???
The problem is that you create an array of 10 items and then stuff 13 numbers into it. So you're using memory that wasn't allocated to the array. To fix this, each time you add more numbers to the array. you need to:
- allocate enough space to hold the old numbers and the new ones.
- copy the old numbers into the new space.
- delete the old space.