Are negative array indexes allowed in C?

后端 未结 8 2326
隐瞒了意图╮
隐瞒了意图╮ 2020-11-22 13:56

I was just reading some code and found that the person was using arr[-2] to access the 2nd element before the arr, like so:

|a|b|c|         


        
8条回答
  •  青春惊慌失措
    2020-11-22 14:54

    What probably was that arr was pointing to the middle of the array, hence making arr[-2] pointing to something in the original array without going out of bounds.

提交回复
热议问题