Reputation:
Considerarray
is an array of variables of type structure
(struct).
When you pass an array of structs as a parameter to a function, you access it with the dot (.
) operator:
array[0].structField1
Shouldn't it be accessed with the arrow (->
) operator, since we're passing the address of the first element of the array, like:
array[0]->structField1
Upvotes: 3
Views: 676
Reputation: 225827
The array index operator []
contains an implicit pointer dereference. So if array
has either array-of-struct or pointer-to-struct type, then array[0]
has struct type and not pointer type.
Upvotes: 7