1D and 2D Arrays

This is a discussion on 1D and 2D Arrays within the C++ Programming forums, part of the General Programming Boards category; Just out of curiousity, would a 1D Dynamic Array take up more space than a 2D Dynamic Array? The 1D ...

  1. #1
    Registered User
    Join Date
    Feb 2005
    Posts
    5

    1D and 2D Arrays

    Just out of curiousity, would a 1D Dynamic Array take up more space than a 2D Dynamic Array?

    The 1D looking like this:
    Code:
    int *array;
    array = new int[25];
    And The 2D looking like this:
    Code:
    int **array;
    array = new *int[5];
    for (int n = 0; n < 5; n++)
    {
        array[n] = new int[5];
    }

  2. #2
    Chief Code Coloniser!
    Join Date
    Apr 2005
    Posts
    121
    You've got 5 more pointers in the second example.... so do the math

    Yes, it'd take up more "space", but in this case it's hardly drastic.

  3. #3
    Kiss the monkey. CodeMonkey's Avatar
    Join Date
    Sep 2001
    Posts
    907
    I like whatever[x][y] personally.
    "If you tell the truth, you don't have to remember anything"
    -Mark Twain

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. multiplying a 2D array by a 1D array
    By youngvito in forum C Programming
    Replies: 14
    Last Post: 06-12-2009, 03:50 PM
  2. from 2D array to 1D array
    By cfdprogrammer in forum C Programming
    Replies: 17
    Last Post: 03-24-2009, 10:33 AM
  3. Pointers to 2D arrays
    By bertazoid in forum C Programming
    Replies: 16
    Last Post: 02-26-2009, 03:46 PM
  4. 2D Array's, assigning chars.
    By gman89 in forum C Programming
    Replies: 9
    Last Post: 04-26-2008, 11:03 PM
  5. Initialising 2D and 3D arrays
    By fry in forum C++ Programming
    Replies: 5
    Last Post: 08-01-2002, 04:34 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21