when do we delete char*?

hi all,

Can anyone explain to me when do we need to delete/free char pointers?
Should it be delete or free when deallocating the memory used?


Thanks!
You delete (or delete[]) it when you longer need it and when it points to a char object that you created with new or new[].
I'm not sure what your confusion with char* is. The fact that a pointer points to a char doesn't make any difference to when you should delete it. Like Athar said, delete/delete[] when you used new/new[] and also, free when you used malloc. Don't mix between them
You shouls delete/free only if it created with new/malloc, not if it is created on the stack.
Topic archived. No new replies allowed.