Some simple code doesn’t appear to be working, and I’m not sure why.

I’m dynamically creating an array of integers. The size of this array is shown as 15, but that’s just because I’m trying to debug the program. The actual size is variable at runtime.
I browsed a few sites for how to dynamically create an integer array in C++. Sites like this one came up. Their code looks like my code: an array is created, and a for loop sets the value of each element in the array.
But after my for loop runs, I get an array of size 0. What could be the problem?
This is an extremely basic C++ program compiling on Windows using Visual Studio.
The debugger doesn’t know it’s a pointer to the start of an array, it thinks you have a plain pointer to an
int(since that is the type ofarray:int*). So it shows the value of thatint(the first element in the array), which is0here.Your code is fine; you have indeed allocated (and initialized) an array of 15
ints correctly.