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
Printable View
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
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
[email protected]
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
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.
[email protected]