3d arrays~

This is a discussion on 3d arrays~ within the C++ Programming forums, part of the General Programming Boards category; Please check this line below, it omits the first dimension, how would the array like this be ??? PHP Code: ...

  1. #1
    flashing vampire black's Avatar
    Join Date
    May 2002
    Posts
    563

    3d arrays~

    Please check this line below, it omits the first dimension, how would the array like this be ???
    PHP Code:
    int myarray[][3][4
    Never end on learning~

  2. #2
    TK
    Guest
    The 3d array gives me a headache, I would have to look that one up, but you can leave the first element in a 2d array if you initialize the array like so.

    Code:
    #include<stdio.h>
    
    int main()
    {
      int array[][3] = {
        {1,2,3},
        {4,5,6},
        {7,8,9},
        {10,11,12}
        };
    
      int i;
      int ii;
    
      for(i=0;i< sizeof(array) / sizeof(array[0]) ; i++)
        {
          for (ii =0; ii < sizeof(array[0]) / sizeof(array[0][0]); ++ii )
            {
              printf("%d ",array[i][ii]);
            }
          printf("\n");
        }
    
      return 0;
    }

  3. #3
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,742
    Well you can omit the first dimension when initialising an array as TK has shown.

    You can also omit the first dimension when declaring an array as an extern.

    extern int myarray[][3][4];

    And you can also omit the first dimension when declaring a function prototype.

    void foo ( int myarray[][3][4] );

  4. #4
    TK
    Guest
    When you declare it with the 'extern' keyword, does this mean that you have to define it in another file?

    If so, than when you define it you have to initialize it in the definiton?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. 3d graphics without API
    By h3ro in forum Game Programming
    Replies: 6
    Last Post: 05-31-2008, 12:51 PM
  2. A 3D Program for my 3D models...?
    By Rune Hunter in forum C++ Programming
    Replies: 26
    Last Post: 08-19-2004, 11:04 AM
  3. 3D starfield
    By VirtualAce in forum Game Programming
    Replies: 6
    Last Post: 06-26-2003, 01:40 PM
  4. 3D SDK for C++ programmers
    By chand in forum Game Programming
    Replies: 2
    Last Post: 05-20-2003, 08:38 AM
  5. 3d engines
    By Unregistered in forum Game Programming
    Replies: 7
    Last Post: 12-17-2001, 11:19 AM

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