c - what pointer magic is this -


i learning c. starting understand pointers , type casting. following along guides , examples , ran across declaration:

uint32_t *sp; ... *(uint32_t*)sp = (uint32_t)somevalue; 

what happening here? first asterisk mystery me.

breaking down:

*(uint32_t*)sp  

basically says treat sp pointer uint32_t ((uint32_t *) cast expression), , dereference result.

so,

*(uint32_t*)sp = (uint32_t)somevalue; 

means, "take somevalue, convert type uint32_t, , store result thing sp points to, , treat thing though uint32_t."

note cast on sp redundant; you've already declared pointer uint32_t, assignment written as

*sp = (uint32_t) somevalue; 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -