Difference between [i] + 1 and [i + 1]

4

I have questions regarding [i] + 1 and [i + 1] , one increa position and the other content, correct?

Regarding the (*i)++ notation, is it similar to the two above?

    
asked by anonymous 15.05.2018 / 15:43

1 answer

6
  

I have questions regarding [i] + 1 and [i + 1] , one increa position and the other content, correct?

Actually the first, [i] +1 , returns what is in the summed position of 1 .

While the second, [i + 1] , returns the combined position of 1 .

None of them actually increment the value unless you make an assignment in the same statement, like this:

arr[i] = arr[i] + 1

So it would not be correct to say that it increases.

  

Regarding the (*i)++ notation, is it similar to the two above?

None since you are using the ++ increment operator and so would be equivalent to doing [i]++ .

Equivalent to [i] +1 would be *i + 1 , and equivalent to [i + 1] would *(i+1) .

    
15.05.2018 / 17:02