negative array index read
Posted cleverlzc
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了negative array index read相关的知识,希望对你有一定的参考价值。
Memory - illegal accesses:negative array index read
负的数组索引读取
This is only valid if arr
is a pointer that points to the second element in an array or a later element. Otherwise, it is not valid, because you would be accessing memory outside the bounds of the array. So, for example, this would be wrong:
int arr[10];
int x = arr[-2]; // invalid; out of range
But this would be okay:
int arr[10];
int* p = &arr[2];
int x = p[-2]; // valid: accesses arr[0]
It is, however, unusual to use a negative subscript.
详细:http://stackoverflow.com/questions/3473675/are-negative-array-indexes-allowed-in-c
以上是关于negative array index read的主要内容,如果未能解决你的问题,请参考以下文章
Maximize Sum Of Array After K Negations
LeetCode --- 1005. Maximize Sum Of Array After K Negations 解题报告
LeetCode --- 1005. Maximize Sum Of Array After K Negations 解题报告
successful NUMA node read from SysFS had negative value (-1)告警的处理方法
leetcode 1005 Maximize Sum Of Array After K Negations & leetcode 1006 Clumsy Factorial
IUrlHelper ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than