This question is related to this one. Given this code:
char *p = new char[200]; delete[] p;
what would happen if you set p[100] = '\0' before deleting p?
I had some code where I got a debug error when I tried to delete a not null-terminated char array, something about deleting heap memory that’s not assigned. It seemed to delete memory out of the array’s bounds.
The code:
is perfectly valid C++. delete does not know or care about null-terminated strings, so your error must have had some other cause.