Click to See Complete Forum and Search --> : Dynamic 2D array
Hi,
Anyone has any ideas how to dynamically create a 2D array using new?
I want to create a dynamic array of an array of BYTES.
thanks
BarD
May 13th, 1999, 06:47 AM
If I understand You properly, you need something like this:
int nrArrays=5;
int nrItems=10;
BYTE** pTwoDimArray;
pTwoDimArray = new BYTE*[nrArrays];
for (int i=0; i<nrArrays; i++) {
pTwoDimArray[i] = new BYTE[nrItems];
}
pTwoDimArray[1][2] = 50;
//fill array the way you want.
Dmitry Barashev
dbarashev@mail.ru
Normen Müller
May 16th, 1999, 06:14 AM
Hi!
Just a little mistake or typing error. You forgot to store the address of the new row in the jump table
of the 2D array.
pTwoDimArray[i] = new BYTE[nrItems];
Bye...
apartis AG http://www.apartis.de
Normen Mueller
BarD
May 16th, 1999, 06:59 AM
I think it is a feature of codeguru markup. There actually must be pTwoDimArray<i> (in square brackets), but as long as <i> in square brackets is a format tag, it is not shown... :( even if you put ccode tag...
Dmitry Barashev.
dbarashev@mail.ru
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.