Basics Of How Array Traversal Works
7 February, 2009 § Leave a comment
Often times you will see an array position referenced as:
int arrNumbers; arrNumbers = 3;
Did you know this is the same as writing:
(*arrNumbers + 2)
The reason that both of these are equal is due to the fact that when you use the operator, pointer arithmatic is getting the memory location of the array and incrementing the position of the variable that you want to look at. When you declare an array of size n, you are allocating a sizeof(type)*n block of memory. The operator simply references locations within that block of memory.