Hi!
This is my first post here on cplusplus.com.
I'm fairly new to programming and I was making a small program that keeps taking integers from the user and place them in a dynamic array.
Once the user enters the number zero, the input loop stops and then the program calculates the average of all the numbers entered. I already got the code to work perfectly fine, but I have a couple of questions:
1. I learned how to create dynamic arrays from this website, but I didn't really get why we use this code
|
int i, *input = new int[i];
|
Can someone please simplify and explain it to me? (keeping in mind that I'm a noob!) I do have some background about pointers, but the
new int
part is confusing me a little.
2. Reading through the forums here, I picked up that I have to delete the dynamic array after using it (I'm guessing to save memory), but every time I use
delete[] input;
, I get a debugging error.
So the second question is: why do I get an error when I add
delete[] input;
?
Any feedback is VERY appreciated!
Thanks!