My array:
int (*arr)[100] = new int[100][100];
How should I correctly delete this?
edit: I know how delete works, but i am not sure if I should delete it like this
delete[] arr;
or like this
for(int i = 0; i < 100; i++) {
delete[] arr[i];
}
delete[] arr;
A simple delete[] arr;
should do just fine.
Whether you are freeing new int[100][100][100][100]
or new int[100]
you use delete[] x;
. If it's a single object, you use delete x;
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.