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
And then I would like to free up the memory. Do I have to do something like the following: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]); }
or do I just need to doCode:for(int i=0; i < argc; ++i) { delete [] args[i]; } delete [] args;
Also, how can I tell if the memory has been freed??Code:delete [] args;
And could anyone suggests a good tutorial on memory allocation in C++?
Thanks
Mark



LinkBack URL
About LinkBacks


