pass tridimentional arrays

This is a discussion on pass tridimentional arrays within the C++ Programming forums, part of the General Programming Boards category; Hi, all~ we know arrays could be passed as arguments but tridimentional arrays looks a bit different from simply arrays. ...

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

    pass tridimentional arrays

    Hi, all~

    we know arrays could be passed as arguments but tridimentional arrays looks a bit different from simply arrays. That is, we could implement our function like this:

    Code:
    int myFunction (int arr[][4][5]);
    why the first [] could be blank ?
    Never end on learning~

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >why the first [] could be blank ?
    The function doesn't need the first dimension to determine the size of the array. Simplified, this:

    void func ( int array[10] );
    is equivalent to
    void func ( int *array );

    Notice that the one dimensional array is converted to a simple pointer, so no size information is needed. A multidimensional array however, needs size information for the latter dimensions:

    void func ( int array[10][10] );
    is equivalent to
    void func ( int (*array)[10] );

    The first dimension is still a pointer, but the second is an array reference, it needs a size.

    -Prelude
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. sorting number
    By Leslie in forum C Programming
    Replies: 8
    Last Post: 05-20-2009, 05:23 AM
  2. Replies: 16
    Last Post: 01-01-2008, 04:07 PM
  3. Help with arrays and pointers please...
    By crazyeyesz28 in forum C++ Programming
    Replies: 8
    Last Post: 03-17-2005, 01:48 PM
  4. Pass by reference
    By mcgeady in forum C Programming
    Replies: 11
    Last Post: 02-17-2005, 03:01 AM
  5. sorting arrays
    By Unregistered in forum C++ Programming
    Replies: 3
    Last Post: 10-13-2001, 06:39 PM

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