附上之前两个例子:
sizeof第二发
sizeof第一发
彻底理解sizeof的一个例子:
- #include <stdio.h>
- int main(int argc, char *argv[])
- {
- double* a[2][3];
- printf("%d\n", sizeof(a));
- printf("%d\n", sizeof(*a));
- printf("%d\n", sizeof(**a));
- printf("%d\n", sizeof(***a));
-
-
- double* (*b)[2][3];
- printf("%d\n", sizeof(b));
- printf("%d\n", sizeof(*b));
- printf("%d\n", sizeof(**b));
- printf("%d\n", sizeof(***b));
- printf("%d\n", sizeof(****b));
- return 0;
- }
复制代码
输出:
24
12
4
8
4
24
12
4
8
|
|