I was working through Bleep in the C++ course in the section on references-pointers found here:
There are a couple instances in the solution, inside nested loops, that have somethings like this:
if ( text [ i + j ] == word [ j ] )
In this instance ’ i ’ is from the first for loop and the ’ j ’ is the second nested for loop. I’m confused about which values are being passed and what we’re comparing. I assume we’re trying to compare letter values to one another? But in that case why are we adding ’ i + j '? Why wouldn’t it just be text[ i ] == word [ j ]? I’ve written it out on paper and am still confused about how it works. At least numerically it would seem that no matter if the letters match or not, during the first loop of ’ j ’ that i = 0 so no matter what ’ i + j ’ will always == [ j ]. But if instead we’re looking at what letter values in the portions held at text[i] and word[i] what is happening with text[i + j]? Hopefully this confusion makes sense and someone can explain what is happening. Thank you!