"joe" <sw******@hotmail.comwrote in message
news:Hq*******************@news-wrt-01.rdc-nyc.rr.com...
>
"Chris" <Th*******@gmail.comwrote in message
news:11**********************@79g2000cws.googlegro ups.com...
>>
joe wrote:
>>hi all,
I have perused the internet a bit and don't see a simple beginner's
answer.
All I need right now is how to declare a multi-dimensional array in C++.
// one dimensional array - simple enough
int array[4] = {0,0,0,0};
// two dimensional array - ?
int array[4][5] = {0,0,0,0 ... ?
thx!
try:
int array[2][2] { {1, 2},
{3, 4} };
that should give you the idea..
I see it, thx!
// arr4: passes a multidimensional array as a paramter
//
// 12/12/06
// 9:11 PM
// This worked just fine. Thanks again! :)
#include <iostream>
using namespace std;
// DECLARATIONS
void printArray (int arg[][3][3], int i, int j, int k)
{
cout << "\n";
for (int n = 0 ; n < i ; n++)
{
for (int m = 0 ; m < i ; m++)
{
for (int l = 0 ; l < i ; l++)
{
cout << " " << arg[n][m][l] << " ";
}
cout << "\n";
}
cout << "\n";
}
cout << "\n";
}
int main ()
{
// INPUT
int array1[3][3][3] = { { { 1, 2, 3}, { 4, 5, 6}, { 7, 8, 9} },
{ {10, 11, 12}, {13, 14, 15}, {16, 17, 18} },
{ {19, 20, 21}, {22, 23, 24}, {25, 26, 27} }
};
// CALCULATIONS
// OUTPUT
printArray(array1, 3, 3, 3);
// EXIT
cout << "\n done.\n";
return 0;
}