CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Oct 2001
    Posts
    6

    array point to array

    hello, i need some help, i need to have each index in a single array point to a double array. please help.
    thanks.

    - dima


  2. #2
    Join Date
    Sep 1999
    Location
    NJ
    Posts
    1,299

    Re: array point to array

    Define "double array". An array of doubles? or a 2-dimensional array?

    I'll do the former; It's easier:typedef double DOUBLE10[10]; // Double10 is an array of 10 doubles.
    DOUBLE10 LotsODoubles[5];
    // LotsODoubles is a array of 5 DOUBLE10,
    // each of which is an array of 10 doubles
    //
    double d = LotsODoubles[2][4];




    Truth,
    James
    http://www.NJTheater.com
    http://www.NovelTheory.com
    I don't do it for the points (OK, maybe I do), but rating a post is a good way for me to know if I helped.

  3. #3
    Join Date
    Oct 2001
    Posts
    6

    Re: array point to array

    Sorry, i actually meant a 2 dimensional array. but thanks


  4. #4
    Join Date
    Oct 2001
    Posts
    6

    Re: array point to array

    if you happen to know how to do the 2 dimensional arrays linked to the indexes of a 1 dimensional array, i would be very grateful.

    - Dima


  5. #5
    Join Date
    Sep 1999
    Location
    NJ
    Posts
    1,299

    Re: array point to array

    Not a problem, each follwo the pattern:
    typedef int DIM1[10]; // DIM1 is a 1-dimension array.
    typedef DIM1 DIM2[10]; // DIM2 is a 2-dimension array (an array of DIM1s)
    DIM2* pArray = new DIM2[n]; // pArray is an 3-dimension array (an array of DIM2s)
    // (Note that pArray is an actuall array, while DIM1 and DIM2 are just types)
    // alternately:
    //
    DIM2** pArray2 = new DIM2*[n];
    // pArray2 is an array of pointers to DIM2s
    for(int i =0; i< n; i++)
    pArray[ i ] = new DIM2;
    // don't forget to delete each item.







    Truth,
    James
    http://www.NJTheater.com
    http://www.NovelTheory.com
    I don't do it for the points (OK, maybe I do), but rating a post is a good way for me to know if I helped.

  6. #6
    Join Date
    Oct 2001
    Posts
    6

    Re: array point to array

    thanks, this helps a lot


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