根据结构体中一个元素的地址 怎么获取其他指针元素的值呢

数据结构定义如下:

typedef struct a_s{
long long id_;
}a_t;

typedef struct b_s{
int seq_;
int c_;
}b_t;

typedef struct test_s{
a_t a_;
b_t *b_;
}test_t;

calloc一个test_t t1 对象。如果已知该对象的a_的地址,怎么能获取到t1的b指针对应的c的值呢?

自己原来写的代码如下,取的时候有问题:
int offset = offsetof(struct test_s,b_);

int a_add = (int)&(t->a_);
int b_add = a_add + offset;
b_t *b1 = (b_t *)*b_add;
    int c = b1->c_;
    printf("%d\n",c);

谢谢各位。

不知道你这个问题是否已经解决, 如果还没有解决的话:

如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 以帮助更多的人 ^-^