“delete [] pointer” does not delete all the memory array? [duplicate]
问题 This question already has answers here : Can a local variable's memory be accessed outside its scope? (20 answers) Dynamically allocating an array of objects (7 answers) Closed 5 years ago . I'm pretty new to C++. I have to delete the pointer and memory allocation, once I complete the cycle. I am using new() for memory allocation and delete at the end to free the data. The program is as follows: int main() { float *ptr; ptr = new float[16]; for(int i=0; i<16; i++) { ptr[i] = 10.0f+i; cout <<