- 论坛徽章:
- 0
|
#include <stdio.h>
struct test {
int data;
int name;
};
struct bwt {
struct test atest;
int first;
int second;
int third;
};
int main()
{
struct bwt test1[4];
test1[0].atest.data = 50;
test1[0].atest.name = 70;
test1[0].first = 10001;
test1[0].second = 200;
test1[0].third = 300;
printf("test1.atest.data:\t%d\ntest1.first:\t%d\ntest1.second:\t%d\ntest1.third:\t%d\n", test1[0], test1[0].first, test1[0].second, test1[0].third);
return 0;
}
===========程序结果===================
deron@deron-desktop:/home/work$ ./test
test1.atest.data: 50
test1.first: 70
test1.second: 10001
test1.third: 200
希望各位大虾能否解释下上面这个问题。在获取test1.atest.data的值得时候直接用test1[0],这样导致后面test1[0].first,test1[0].second, test1[0].third都不能获得正确的。 |
|