Simple 3D Array C++

后端 未结 5 1599
深忆病人
深忆病人 2021-02-05 13:57

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         


        
5条回答
  •  一个人的身影
    2021-02-05 14:31

    Your syntax is wrong.

    int a[2][2][3] = {     // Initialize entire variable
      {                    //   1 of 2 (leftmost array)
        { 1, 2, 3 },       //     1 of 2 (inner array)
        { 4, 5, 6 },       //     2 of 2 (inner array)
      },
    
      {                    // 2 of 2 (leftmost array)
        { 7, 8, 9 },       //     1 of 2 (inner array)
        { 10, 11, 12 },    //     2 of 2 (inner array)
      },
    }
    

    What you've shown would be an int [8][2].

提交回复
热议问题