Why does the arrow (->) operator in C exist?
11 points by signa11 10 hours ago | 4 comments
  • furyman 9 hours ago |
    Majorly for reference. Reference to memory. I've seen mostly being used to carry pointer based operations. It make memory management efficient and also helpful in mindful and secure uses of memory.
  • rurban 9 hours ago |
    To denote that it is more costly than .
  • Tor3 8 hours ago |
    As was mentioned in one of the comments which actually described what the real cause was, it came from the original Ritchie C which had a syntax which in some cases differed a lot from what eventually became C. And in that version it did make sense to use a different operator. That reason disappeared when C as we know it came around, but the -> operator stayed. The real question is then why that wasn't reworked as well, when the underlying cause was.
  • glouwbug an hour ago |
    Probably because (*p).field already worked