Hello:
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,
int p[10];
I would do
int *p;
int x=10; // OR available thru user input
p = new int [x];
but what I have currently is:
int *p[2][5]; // array of 2x5 pointers [\code]
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:
[code=c] (int *) (* p[2]); [\code]
Not sure how to go around allocating space for the second dimension of the array?
Any help would be appreciated.
Thanks.[code=c]
int *p[2][5]; // array of 2x5 pointers
[\code]
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:
(int *) (* p[2]); [\code]
Not sure how to go around allocating space for the second dimension of the array?
Any help would be appreciated.
Thanks.[code=c]
(int *) (* p[2]);
[\code]
Not sure how to go around allocating space for the second dimension of the array?
Any help would be appreciated.
Thanks.