# Thread: Difference between arr and &arr where arr is 1D array

1. ## Difference between arr and &arr where arr is 1D array

Hi

I have following program

Code:
```main()
{
int arr[]={1,2,3};
printf("%u %u",arr,&arr);
printf("%u %u",arr+1,&arr+1);

}```
While printing arr and &arr are giving same address but arr+1 and &arr+1 aregiving different address. What is the difference between arr and &arr

Thanks

Sas

2. arr has the address to the base of an array of three int's.

&arr is the address of the first element of that same array.

You've arrived at the same address, by going two slightly different ways to get there.

3. Why arr+1 and &arr+1 is different?

4. Well, I think that you should start your understanding of this by answering the following questions:

1) what is the type of arr
2) what is the type of &arr

5. Originally Posted by SasDutta
Why arr+1 and &arr+1 is different?
You're being difficult today, aren't you?

arr+1 is just the address of the base of the array, plus the address of an int, added on, (since the array knows that it's an int array).

Caught you before you could ask, didn't I?

The answer I get with &arr + 1 is the first address after the array. Which leads me to believe (and I don't know for sure), that K&R set it up to conveniently handle arrayname + number to be the address of the base, and to exclude any info on the size of the array, just for the sake of convenience for the programmers. &arrayname + number, was never set up for that, and converts to the first address for the type, beyond the end of the array.

arr has the address to the base of an array of three int's.

&arr is the address of the first element of that same array.
It's actually the other way around.

arr is an array. It is also (equivalent to) a pointer an int, which contains the address of the first element of the array.

&arr is the address of an array of three ints. It is of type pointer to an array of three ints.