heaveneye
asked on
Appropriate way to delete this pointer
It happened that I need to manage some other people's source code. In the source, I found that a pointer it was instantiated as below was not freed after being used:
TCHAR** val= NULL;
val = new TCHAR*[MAX_NB];
However, I am unsure the appropriate way to free up the pointer. I am wondering the followings:
delete val[]; // <----- is this appropriate? or should it be "delete val[][]" ?
val=NULL;
I am quite young on c++ programing, and need some advice from experts.
TCHAR** val= NULL;
val = new TCHAR*[MAX_NB];
However, I am unsure the appropriate way to free up the pointer. I am wondering the followings:
delete val[]; // <----- is this appropriate? or should it be "delete val[][]" ?
val=NULL;
I am quite young on c++ programing, and need some advice from experts.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks
free(val);
This will free the memory and set tour pointer to NULL.