I've been reading the Big Nerd Ranch book on Obj-C and before I get to the chapter on Obj-C and objects, I'm making sure I understand everything he is teaching us about C.
My confusion regards structs... When he first introduces structs he says you are able to access it's members simply like:
However, a few pages later (or maybe it is the next chapter) he talks about accessing members of a struct using pointers, but instead of * he uses -> ... There is very little explanation about why -> is used though. If I'm able to access a struct just by saying person.age = 29; then the variable's scope must be available much like a global variable would be so why would I need to use -> ?
My confusion regards structs... When he first introduces structs he says you are able to access it's members simply like:
Code:
typedef struct {
int age;
float weight;
} Person;
int main(int argc, const * char argv[]) {
Person person;
person.age = 29; //very simple
person.weight = 175;
return 0;
}
However, a few pages later (or maybe it is the next chapter) he talks about accessing members of a struct using pointers, but instead of * he uses -> ... There is very little explanation about why -> is used though. If I'm able to access a struct just by saying person.age = 29; then the variable's scope must be available much like a global variable would be so why would I need to use -> ?