Regarding pointers (in structs for this case), I understand that if 'a' were a struct and 'b' declared within the struct, then we can access the data through:
a->b
And now, I've recently found out C has a lot of shortcuts regarding pointers, one of which would be the arrow operator as above.
I've seen 'a->b' being written as '[a] + b', such that:
a->b <=> [a] + b //meaning that they are interchangeable
However, I am having trouble making sense of this what '[a] + b' actually means and would really appreciate someone laying the details out for me (or perhaps I misread and the above is nonsense !). Many thanks in advance!
[]operator requires two arguments because the expressionp[i]is equivalent to*(p+i). I can't see how[a]alone is valid C.[a] + b? can you provide some example?[]operator certainly does exist, but the example you provided is not how they are used. Like I said, the[]operator is for accessing elements of an array, not members of a structure. That's what the->operator is for (so thata->bis equivalent to(*a).b). You should certainly ask your teacher about this unusual "operator".