If I have a struct like
struct account {
int account_number;
};
Then what\'s the difference between doing
myAccount.acco
You use . when you're dealing with variables. You use -> when you are dealing with pointers.
For example:
struct account {
int account_number;
};
Declare a new variable of type struct account:
struct account s;
...
// initializing the variable
s.account_number = 1;
Declare a as a pointer to struct account:
struct account *a;
...
// initializing the variable
a = &some_account; // point the pointer to some_account
a->account_number = 1; // modifying the value of account_number
Using a->account_number = 1; is an alternate syntax for (*a).account_number = 1;
I hope this helps.