Being C++ is not just about writing code that can be compiled by the C++ compiler. It is a style of writing code. This is a typical C style. It just happens to compile under C++ compiler but itsit's not C++.
In this case its not just a pointer its: it's an array, the. The trouble here is that the array has decayed so we can't actually tell that it is an array anymoreany more and just have to assume the caller has not done something stupid. In C++ we like to understand the object being passed so we can use it correctly.
In C++ (uptoup to C++17) we would normally represent this as iterators:
Note a Range basically supports begin() and end() and is interchangeable with a View. If I got thethat incorrect sorry, then sorry: we are still getting used to these concepts as they are new to C++.
What are you trying to achieve.? Vertical space-saving is not a good style. Make it clear as possilepossible to use.
I know a lot of people use i/j for loop variables (especially coming from C or FORTRAN). But it is objectively a bad choice. Once you start adding comments to your code searching for i and j in the code gives you way totoo many false hits when trying to find all the use cases. So unless your loop is literally one line obvious and the loop variable is only used in one place don't do it. Even if all the above is true, don't do it because the code will change over time and writing it expressively now will save time later.
I would separate this additionadditional line out into its own function (with a very explanation based-based name) so it documents why you are adding this up in a particular order. This will be important for future maintainers as they may not immediately understand why all the braces are there (and do what I did and just remove them to make the code easy to read).
As a side note: prefer ++j over j++. For integers there is nno difference. But if you are looping with other types it can make a minor differencesdifference and the idea is that you want to be optimal whatever the loop type. A lot of C++ code is modified by simply changing the type of the objects and you don't want to change the type then go back and change how it used as well.