KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have a unsigned char pointer which contains a structure.Now I want to do the following unsigned char buffer[24]; //code to fill the buffer with the relevant information. int len = ntohs((record_t*)buffer->len); where record_t structure contains a field called len . I am not able to do so and am getting the error. error: request for member ‘len’ in something not a structure or union. Then I tried: int len = ntohs(((record_t*)buffer)->len); so as to get the operator precedence right. That gave me: warning: dereferencing type-punned pointer will break strict-aliasing rules. then I declared record_t *rec = null; rec = (record_t*) what am I doing wrong here?
Tags (comma-separated)
Save Edits
Cancel