Accessing array values is generally done through square brackets:

``````int val;
int array;

/* Setting the value of the fifth element to 5: */
array = 5;

/* The above is equal to: */
*(array + 4) = 5;

/* Reading the value of the fifth element: */
val = array;
``````

As a side effect of the operands to the `\\+` operator being exchangeable (–> commutative law) the following is equivalent:

``````*(array + 4) = 5;
*(4 + array) = 5;
``````

so as well the next statements are equivalent:

``````array = 5;
4[array] = 5; /* Weird but valid C ... */
``````

and those two as well:

``````val = array;
val = 4[array]; /* Weird but valid C ... */
``````

C doesn’t perform any boundary checks, accessing contents outside of the declared array is undefined (http://stackoverflow.com/documentation/c/364/undefined-behavior/2144/accessing-memory-beyond-allocated-chunk#t=201701141217382606962 ):

``````int val;
int array;

array = 5;    /* ok */
val = array;  /* ok */
array = 20;  /* undefined behavior */
val = array; /* undefined behavior */
``````