Creating 2D arrays on heap
If we have to create a single dimension array on heap, and then deallocate the memory assigned to it, the code would be somthing like this...
Code:
char *array=new char[50];
//....
delete array;
Similarly I need to create a 2D array on heap, and deallocate the memory using double pointers. Please help me out.
Re: Creating 2D arrays on heap
Quote:
Originally posted by sundeeptuteja
Code:
char *array=new char[50];
//....
delete array;
Should actually be
Code:
char *array=new char[50];
//....
delete[] array;