I am getting confused about making a 2 dimensional array of pointers allocate storage space dynamically in C++. Actually I just want the second dimension of the array to be dynamic in size. For e.g. a simpler version of what I want to do would be:
Instead of,
I would do
but what I have currently is:
and want to convert to allow the user to enter the size of second dimension (which is [5] right now). Maybe the declaration will look like:
Not sure how to go around allocating space for the second dimension of the array?
Instead of,
Code:
int p[10];
Code:
int *p; int x=10; // OR available thru user input p = new int [x];
Code:
int *p[2][5]; // array of 2x5 pointers
Code:
(int *) (* p[2]);
Comment