Well all its doing is comparing memory address. Lets look at an example.
Let's assume we have an array called
ar with 5 elements
CODE
int ar[5] = {100, 101, 102, 103, 104};
This array will be located somewhere in memory as a contiguous
block. In this case 4 * 5 = 20 bytes total (4 bytes per int).
Each int in the array will have an address, so it will look something
like this in memory. (mem addresses are made up)
Address: 0x001 0x002 0x003 0x004 0x005
array idx: [0] [1] [2] [4] [4]
Value: 100 101 102 103 104
As shown in the table above the first value in the array
ar has an address of 0x001. Note: The address
scheme here is arbitrary, I increment by 1 just for simplicity.
Real memory addresses are offset by the size of the type.
In your code
ip is assigned the value 0x001
or the address of the array
ar at index 0.
The loop will continue until will the address in
iphas reached some point in the array. In this case 0x020 if we use
the addressing scheme above.
So in short. Its comparing addresses instead of the value of each
element in the array
hope that helps
Edit: D.I.C editor removing whitespace in my table sorry about its alignment
This post has been edited by skaoth: 10 May, 2008 - 08:52 AM