Thread: dimensional arrays

  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,663
    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, 02:28 PM
  3. Two dimensional arrays
    By Masschino in forum C Programming
    Replies: 9
    Last Post: 05-18-2004, 08:17 PM
  4. two dimensional arrays
    By ssjnamek in forum C++ Programming
    Replies: 4
    Last Post: 05-01-2002, 08:12 PM
  5. Two dimensional arrays
    By Jax in forum C Programming
    Replies: 1
    Last Post: 11-07-2001, 12:53 PM