446,327 Members | 1,781 Online
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,327 IT Pros & Developers. It's quick & easy.

# need for simple program of arrays

 P: 23 declare two dimensional array of type double using dynamic memory allocation then write code to delete this two dimensional array??? Oct 1 '06 #1
4 Replies

 P: 23 declare two dimensional array of type double using dynamic memory allocation then write code to delete this two dimensional array??? double *dPtr[5] = new double[5]; delete[ ] dPtr; Oct 1 '06 #2

 100+ P: 293 Expand|Select|Wrap|Line Numbers   int WIDTH;   int HEIGHT;     cout << "Enter array width: ";   cin >> WIDTH;   cout << "Enter array height: ";   cin >> HEIGHT;     char* array2D = (char*)malloc(WIDTH*HEIGHT*sizeof(char));   free(array2D); Oct 2 '06 #3

 P: 23 i asked for a program which declares a two dimensional array of type double using dynamic memory allocation and then delete this array but im a begginer in c++ and i dont know how to completly write it ,i tried and thats it #include using namespace std; int main() { double *dPtr[5]= new double[5]; delete[] dPtr; cout<<&dPtr[]<<" "<

 Expert Mod 5K+ P: 8,916 Please don't double post Unfortunately you have chosen to use the non-working code from this thread instead of the working code. There is no such thing as an allocated 2D array, it's in your head. However you can simulate this imaginary concept like this Expand|Select|Wrap|Line Numbers #include    using namespace std;   int main() {     double *dPtr[5];     double *data = new double[25];       dPtr[0] = data;     dPtr[1] = dPtr[0]+5;     dPtr[2] = dPtr[1]+5;     dPtr[3] = dPtr[2]+5;     dPtr[4] = dPtr[3]+5;       delete data;   //    cout<<&dPtr[]<<" "<