![Quote](https://cboard.cprogramming.com/images/misc/quote_icon.png)
Originally Posted by
tlovaj
i guess my question would be: what does "->" do?
If you have a pointer to a structure, it is a way to access the members of the structure without having to dereference the pointer using the * dereference operator.
Code:
struct foo
{
int a;
double b;
};
int main()
{
struct foo fooObject;
struct foo *pointerToFooObject = &fooObject;
/* Immediate access */
fooObject.b = 7.56;
/* Access with dereference. */
(*pointerToFooObject).a = 5;
/* The shorthand operator -> in action */
pointerToFooObject->a = 12; /* Now fooObject.a is 12 */
return 0;
}