- 论坛徽章:
- 0
|
我在gcc环境下测试下来,不管struct aaa类型的变量在哪里定义,它的成员都是靠在一起的
- #include <stdio.h>
- int refglob = 0;
- const int refconst = 0;
- struct aaa
- {
- const int a;
- int b;
- const int c;
- };
- struct aaa varglob;
- int main(void)
- {
- struct aaa var;
- int refauto = 0;
- printf("&refauto = %p\n", &refauto);
- printf("&refglob = %p\n", &refglob);
- printf("&refconst = %p\n", &refconst);
- printf("&(var.a) = %p, &(var.b) = %p, &(var.c) = %p\n", &(var.a), &(var.b), &(var.c));
- printf("&(varglob.a) = %p, &(varglob.b) = %p, &(varglob.c) = %p\n", &(varglob.a), &(varglob.b), &(varglob.c));
- return 0;
- }
复制代码 |
|