#How to know if array is on heap?

5 messages · Page 1 of 1 (latest)

ancient meadow
#

Hello, I am learning how to use pointers and was wanting to know how I can check if the allocated is space is being used.

here is my code :
` int main(){

int val{0};
cout << "enter a number:\t";
cin >> val;

int *p = new int[val];
cout << "[ ";
for (int i = 0; i < val; i++) {
    p[i] = i+1;
    cout << p[i] << " ";
}
cout << "] \n";

delete[] p;

return 0;

}`

reef harborBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

ancient meadow
#

!solved nevermind I'm having brain fog

reef harborBOT
pure snow
#

!solved