Find an Online Tutor Now

Asked • 05/19/19

Why does the arrow (->) operator in C exist?

The dot (`.`) operator is used to access a member of a struct, while the arrow operator (`->`) in C is used to access a member of a struct which is referenced by the pointer in question.The pointer itself does not have any members which could be accessed with the dot operator (it's actually only a number describing a location in virtual memory so it doesn't have any members). So, there would be no ambiguity if we just defined the dot operator to automatically dereference the pointer if it is used on a pointer (an information which is known to the compiler at compile time afaik).So why have the language creators decided to make things more complicated by adding this seemingly unnecessary operator? What is the big design decision?

1 Expert Answer


Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.


Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.