-2

I' just got started in learning struct in c language. i Thought "->" and "." were equivalent but i get the following error when using "->" instead of ".": invalid type argument of '->' (have 'struct item')

tsumey
  • 63
  • 1
  • 11
  • *i thought "->" and "." were equivalent* is it what your C book teached you? If yes, read it again. – ouah Jan 09 '16 at 11:27
  • I don't think this Question is a bad one. 3 Down votes and only one comment? If you find this Question bad, why someone gives an Answer to it? – Michi Jan 09 '16 at 11:31

1 Answers1

0

a->b is short for (*a).b.

There is no difference between a->b and (*a).b. There is a difference between (*a).b and a.b, of course - which is that the * dereferences a first (which must be a pointer or an array).

user253751
  • 57,427
  • 7
  • 48
  • 90