How can I use delete to free up the memory in a 2D array? Do I need to call it for each of the rows in the array??
So say if I have
Code:
char **args = new char*[argc];
for(int i=0; i < argc; ++i) {
args[i] = new char[strlen(argv[i])+1];
strycpy(args[i], argv[i]);
}
And then I would like to free up the memory. Do I have to do something like the following:
Code:
for(int i=0; i < argc; ++i) {
delete [] args[i];
}
delete [] args;
or do I just need to do
Also, how can I tell if the memory has been freed??
And could anyone suggests a good tutorial on memory allocation in C++?
Thanks
Mark