dimensional arrays

This is a discussion on dimensional arrays within the C++ Programming forums, part of the General Programming Boards category; Can someone please explain how you call upon and list 3 and 4 dimensional arrays? The book isn't explaining very ...

  1. #1
    ___
    Join Date
    Jun 2003
    Posts
    806

    dimensional arrays

    Can someone please explain how you call upon and list 3 and 4 dimensional arrays? The book isn't explaining very well and I'm stuck. I've done some google searches on it but there isn't anything there for a dumb person.
    "When I die I want to pass peacefully in my sleep like my grandfather did, not screaming and yelling like the passengers in his car."

  2. #2
    Registered User
    Join Date
    Apr 2003
    Posts
    2,662
    Code:
    #include<iostream>
    using namespace std; 	
    
    int main()
    {
    	int my_array[2][3][4];
    	for(int i=0; i<2; i++)
    	{
    		for(int j=0; j<3; j++)
    		{
    			for(int k=0; k<4; k++)
    				my_array[i][j][k]=i+j+k;
    		}
    	}
    
    	for(int x=0; x<2; x++)
    	{
    		for(int y=0; y<3; y++)
    		{
    			for(int z=0; z<4; z++)
    				cout<<my_array[x][y][z]<<" ";
    			cout<<endl;
    		}
    		cout<<endl<<endl;
    
    	}
    	
    	return 0;
    }

  3. #3
    Registered User
    Join Date
    Dec 2002
    Posts
    162
    Don't quite understand your question.

    Do you mean declare a 3 or 4 dimensional array?:
    int ArrayName[10][10][10]; // declare a 3d array with the dimensions 10, 10, 10.

    Or, how to use a array list as a call parameter?:
    FunctionName(ArrayName[0][0]); // Give a pointer to the 3rd dimension with the dimensions 0, 0
    We haven't inherited Earth from our parents; instead we have borrowed her from our children - old Indian saying.

  4. #4
    ___
    Join Date
    Jun 2003
    Posts
    806
    Well I meant declareing them and calling on them
    "When I die I want to pass peacefully in my sleep like my grandfather did, not screaming and yelling like the passengers in his car."

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Pointers and multi dimensional arrays
    By andrea72 in forum C++ Programming
    Replies: 5
    Last Post: 01-23-2007, 04:49 PM
  2. Dynamic two dimensional arrays
    By ThWolf in forum C++ Programming
    Replies: 14
    Last Post: 08-30-2006, 03:28 PM
  3. Two dimensional arrays
    By Masschino in forum C Programming
    Replies: 9
    Last Post: 05-18-2004, 09:17 PM
  4. two dimensional arrays
    By ssjnamek in forum C++ Programming
    Replies: 4
    Last Post: 05-01-2002, 09:12 PM
  5. Two dimensional arrays
    By Jax in forum C Programming
    Replies: 1
    Last Post: 11-07-2001, 12:53 PM

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