Are C multidimensional arrays contiguous without holes?
问题 I am unable to find in the C standard docs specifically where it says that multidimensional arrays are contiguous. While it can be inferred from the fact that array elements are contiguous, I want some perspective from the community. The following code prints out the numbers in the order that I would expect, which is 1 - 9. #include <stdio.h> int main() { int a[][3] = {{1,2,3},{4,5,6},{7,8,9}}; int* p = (int*)a; int i; for (i = 0; i < sizeof(a)/sizeof(int); i++) printf("%d ",p[i]); return 0;