|
-
May 13th, 1999, 03:33 AM
#1
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
-
May 13th, 1999, 06:47 AM
#2
Re: Dynamic 2D array
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]
-
May 16th, 1999, 06:14 AM
#3
Re: Dynamic 2D array
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
-
May 16th, 1999, 06:59 AM
#4
Re: Dynamic 2D array
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]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|