联合内部的struct和具有struct指针的联合。如何访问它们?

我正在研究结构和联合。

typedef struct _test {

        int te; 

}test;

typedef struct _resp {

        int type;
        union {
                test *testptr;    
        }u;

}resp_t;

resp_t *resp;

如何使用resp访问te?

ccxygc2008 回答:联合内部的struct和具有struct指针的联合。如何访问它们?

  

如何使用resp访问te?

resp->u.testptr->te;
,

不要忘记为resp_t结构分配足够的空间。
要访问该元素,只需执行resp->u.testprt->te

本文链接:https://www.f2er.com/3040427.html

大家都在问