I've been using a method to loop through an array in C that involves a pointer and decrementing the size variable. My loop looks like this: for (; a < a + n; a++, n--) where 'a' points to the first element of the array (or a row in a multidimensional array), and 'n' is the size of that row or the entire array. I'm curious about whether this method is safe and if using subscripting might be a better approach.
2 Answers
Honestly, I'm not a fan of this approach. It can make the code harder to read since it replaces a common looping structure with something that might confuse readers. Code should be as clear as possible!
I think readability should come first, so I don't see this as an improvement. There's nothing wrong with the traditional way of looping. That said, it’s cool to experiment with different methods!
Do you think this method has any performance benefits?

Totally agree! Clever tricks can often lead to unmaintainable code.