I am a novice in C++ and I am trying to create a simple static 3 Dimensional Array and then print it out in console.
Here is my current code:
#include &l
Your declare a 2x2x2 array, but defining it as a 2x8 array.
Also, when you print the content of your array, you use MAX_* as indexes instead of your loop variables.
#include
int main()
{
const int MAX_ROW = 2;
const int MAX_COL = 2;
const int MAX_HEIGHT = 2;
int MyArray[MAX_ROW][MAX_COL][MAX_HEIGHT] = {
{
{1,1}, {1,-1}
},
{
{2,10}, {2,-10}
}
};
for(int Row = 0; Row < MAX_ROW; ++Row)
for(int Col =0; Col < MAX_COL; ++Col)
for(int Height = 0; Height < MAX_HEIGHT; ++Height)
std::cout << "Integer["<< Row << "][" << Col << "][" << Height << "] = " << MyArray[MAX_ROW][MAX_COL][MAX_HEIGHT] << std::endl;
return 0;
}