有没有一种方法可以打印整个数组,而不仅仅是通过遍历数组来打印数组的内容?

Is there a way to print an entire array and not just printing the contents of the array by iterating through them?

C中,有没有办法打印整个数组。例如打印(完整)二维数组中的每一行,而不是遍历其内容并独立打印它们?下面是我想象中的代码示例:

int main() {
int Numbers[4][4] = {{5, 1, 1, 6},
                          {2, 2},
                          {3, 3, 3},
                          {4, 4, 4}};


for (int i=0; i<=3; i++){
    printf("%i \n", Numbers[i]);

}

return 0;
}

我希望输出是这样的:

{5, 1, 1, 6}
{2, 2}
{3, 3, 3}
{4, 4, 4}

但是,当 运行 代码时,我得到以下输出

-414054224 
-414054208 
-414054192 
-414054176 

不,无法按照您的要求进行操作。你不能在 C 中对整个数组进行操作;您必须遍历并分别打印每个元素。在大多数情况下,C 中的数组表达式会失去其“数组特性”。