What is the diff between * and ->
Thanks in adv.
What is the diff between * and ->
Thanks in adv.
-> is used to abbreviate a pointer to a member of a structure:
(*p_part).number = p_part->number
You don't normally compare the two. * is a symboling telling the compiler that you want to go *indirectly* through a variable (making it a pointer).
-> on the other hand, is used for reference the fields of a structure, when you only have a pointer to the structure, not the actual structure itself, to work with.
Don't forget there's two different versions of *. One is for referencing, or declaring the pointer like has been mentioned, and one is for retrieving the value stored in the memory address contained in the pointer.