|
Hello David,
There are 2 ways to do this.
1. If we have to fix any one of the array dimension
at the declaration itself then the array declaration and allocation will looks
like this.
const int n = 1024;
int a;
cout << "Enter the value of a:
";
cin >> a;
int (*nArray)[n];
/*declaration*/
nArray = new int[a][n]
/*definition*/
2. If array dimensions are unknown
int a, b;
int **nArray; /*declaration*/
cout << "Enter the value of a:";
cin >> a;
count << "Enter the value of
b:";
cin >> b;
/*definition*/
nArray = new int*[a];
for (int i = 0; i < a; i++)
nArray[i] = new
int[b];
I think this is what you are looking for. I know
only the above methods to initialize a 2-dimensional array dynamically. Hope
some of this helps you.
Good Luck & Happy Programming.
Sreeram.
|
