declare two dimensional array of type double using dynamic memory allocation then write code to delete this two dimensional array???
need for simple program of arrays
Collapse
X
-
Tags: None
-
plz fix my program!!!
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<iostre am>
using namespace std;
int main()
{
double *dPtr[5]= new double[5];
delete[] dPtr;
cout<<&dPtr[]<<" "<<endl;
return 0;
}Comment
-
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
Code:#include <iostream> 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[]<<" "<<endl; return 0; }
Comment
Comment