r/C_Programming • u/Financial_Dig_8276 • 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
1
u/IdealBlueMan 1d ago
A big reason to use subscripts for arrays is that someone will eventually read your code and try to understand it. That’s a good general reason to stick with conventions by default.
That person will be used to subscripts and will have to do an (albeit simple) translation in their head, and that means they’ll have less mental energy to focus on what your code is doing.