Real thing about "->" and "."
Posted
by fsdfa
on Stack Overflow
See other posts from Stack Overflow
or by fsdfa
Published on 2010-05-26T19:10:38Z
Indexed on
2010/05/26
19:21 UTC
Read the original article
Hit count: 250
I always wanted to know what is the real thing difference of how the compiler see a pointer to a struct (in C suppose) and a struct itself.
struct person p;
struct person *pp;
pp->age
, I always imagine that the compiler does: "value of pp + offset of atribute "age" in the struct".
But what it does with person.p
? It would be almost the same. For me "the programmer", p is not a memory address, its like "the structure itself", but of course this is not how the compiler deal with it.
My guess is it's more of a syntactic thing, and the compiler always does (&p)->age
.
I'm correct?
© Stack Overflow or respective owner