Value of memory changed without permission

前端 未结 3 1173
旧时难觅i
旧时难觅i 2021-01-29 07:01

I have an array with 2 dimensions and when I print the data of the array the first time, the date is printed correctly, but the other times the data of array[last][i] from i = 0

3条回答
  •  清歌不尽
    2021-01-29 07:57

    If you have an array declared as having numero elements then the valid range of indices is [0, numero-1].

    Thus such loops like this

    for (unsigned int i = 0; i <= numero; i++) {
    

    used to access elements of an array with numero elements results in undefined behavior.

提交回复
热议问题