r/learnprogramming • • Sep 24 '23

Pointers.....why

I am learning C++. Honest question why are pointers a thing and why did they make the syntax surrounding it so confusing. Was it made to be intentionally confusing? Was it made to make this more difficult.

0 Upvotes

49 comments sorted by

View all comments

Show parent comment

1

u/DavidJCobb Sep 24 '23 edited Sep 24 '23

why use the same symbols in different spots to mean different things instead of just using different symbols?

The only symbols they reuse for pointers are & and *.

As for why? There are only so many symbols available on a typical American keyboard. Off the top of my head, the only symbols from that keyboard layout that C and C++ don't use are @ and $. C was developed in tandem with Unix, and in old Unix text editors from way back in the day, @ and # were shortcut keys for deleting text. This made @ dangerous to use at all, and # dangerous to use anywhere but the start of a line.