CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Guest

    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


  2. #2
    Join Date
    Apr 1999
    Posts
    13

    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]



  3. #3
    Join Date
    May 1999
    Posts
    44

    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

  4. #4
    Join Date
    Apr 1999
    Posts
    13

    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
  •  





Click Here to Expand Forum to Full Width

Featured