Use the memset Function to Clear Char Array in Ch> header file. memset takes three arguments - the first is the void pointer to the memory region, the second argument is the constant byte value, and the last one denotes the number of bytes to be filled at the given memory address.
delete is used for one single pointer and delete[] is used for deleting an array through a pointer.
We can use \u0000 value to create an empty char in Java. The Java compiler uses this value to set as char initial default value.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With