[英]Dereferencing Void Pointer that will point to a structure
我有以下结构:
typedef struct TTCAPMessage {
uint8_t packagetype; //{should be Query /w Permission or Response}
uint32_t transid; //{transaction ID number}
std::vector<TTCAPComponent_t> components; //{a string of component Information elements}
bool parseok; //{false if error occured}
} TTCAPMessage_t;
typedef struct TTCAPComponent {
uint8_t componenttype; //{should be Invoke, Return Result, Reject, etc.}
uint8_t componentid; //{component ID code}
uint8_t operationcode; //Query operation code, "Private TCAP"
void* pParameterSet;
} TTCAPComponent_t;
typedef struct myStruct {
.....
} mySruct_t;
在TTCAPComponent_t中,有一个空*应该指向两种不同类型的结构。 在这种情况下,它将指向myStruct_t。 我想检索其中的数据。
因此,为了取消引用,我尝试了以下多种变体,但没有运气:
tcapMessage->components[0]->(myStruct_t*)pParameterSet->(Accessing Structure data) ....
我尝试过在线查找资源,但是由于某种原因,我无法使它正常工作。 在此先感谢您的帮助!
箭头->
运算符仅接受成员名称作为其右侧,因此您不能在其中放置演员表。 您正在寻找以下语法:
((struct myStruct_t*)tcapMessage->components[0]->pParameterSet)->...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.