negative « index « C Array Q&A

Home
C Array Q&A
 1 bit 2 Byte 3 char 4 class 5 Development 6 Dimensional Array 7 dynamic 8 element 9 find 10 index 11 initialization 12 Integer 13 length 14 loop 15 memory 16 Operation 17 pointer 18 Print 19 size 20 Sort Search 21 string 22 struct 23 variable
 C Array Q&A » index » negative

1. Negative array indexes in C?    stackoverflow.com

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|d|e|f|g|
^------------ ...``````

2. Negative array index in C    stackoverflow.com

There have been other question/answers on negative array in C in the forum, but i would request the answer to these for a 32-bit compiler : If we have an array defined ...

4. negative index in array    bytes.com

say i have a two dimensional array a[512][512]. There is one more 2D array b[512][512]. The algorithm is like this depending on value of a[i][j] i have compare b[j][k] with two of its neighbour. This is a part of that algorithm if(a[j][k]==0) { if(b[j][k]>=b[j][k+1] && b[j][k]>=b[j][k-1]) some code here } the problem is when k=0 b[j][k-1] will be b[j][0-1]=b[j][-1]. To handle ...