Posted By: Anonymous
I am reading a book called “Teach Yourself C in 21 Days” (I have already learned Java and C# so I am moving at a much faster pace). I was reading the chapter on pointers and the
-> (arrow) operator came up without explanation. I think that it is used to call members and functions (like the equivalent of the
. (dot) operator, but for pointers instead of members). But I am not entirely sure.
Could I please get an explanation and a code sample?
foo->bar is equivalent to
(*foo).bar, i.e. it gets the member called
bar from the struct that
foo points to.