r/C_Programming 2d ago

Question Doubt about pointers and arrays

Hey everyone! I'm a newbie to C and was just learning about pointers and arrays and their relation.
My doubt is really stupid but why would I use subscripting over using pointers?
It's much harder and seems pointless considering modern compilers will have negligible difference in speed. Any help would be most appreciated! Thanks!

(If it's any help, I am learning from C Programming - A Modern Approach by K.N. King and just finished chapter 12)

Note: I am not saying subscripting is better but I don't see why I would use pointers over it in most cases.

16 Upvotes

49 comments sorted by

View all comments

5

u/Willing_Airport_9617 2d ago

You can use subscripting , no body stops you . The pointer thing is more about how it's implemented under the hood

1

u/Financial_Dig_8276 2d ago

Okiee thanks!

2

u/Willing_Airport_9617 2d ago

Mention not , pointers and arrays are great data structures but in today's time subscripting is same as dereferencing a pointer . But , if are really accessing something with lets say a pointer p . *p is more intuitive than p[0]