Can you use the arrow operator with an array of type struct. For example:
struct {
char *foo;
} fooArray[10];
fooArray[0]->foo = ...
No, you have to use fooArray[0].foo.
fooArray is a pointer that happens to point to the first element of an array. Using the [] is dereferencing that pointer at the given element so once applied it's no longer a pointer and the -> operator cannot be applied since that operator does both dereferencing and accessing a struct member.
Remember the value of fooArray by itself is a pointer. You can dereference the pointer, add to it, ...
fooArray->foo; /* same as fooArray[0].foo */
(fooArray+3)->foo; /* same as fooArray[3].foo */
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With