When I'm running an example of this.. &arr and arr are giving the same value. How?
Dave said:
(Sat, Aug 20, 2011 12:27:37 PM)
Can anyone explain it in depth. not able to get what they r saying..
Ram said:
(Fri, Sep 30, 2011 10:11:25 PM)
Try this
#include<stdio.h>
int main()
{
int arr[2];
printf("%d \n",arr);
printf("%d \n",(arr+1));
printf("%d \n",&arr);
printf("%d \n",(&arr+1));
}
Rupinderjit said:
(Wed, Nov 23, 2011 05:06:39 PM)
@Ram:You are right ,but the one thing here need to be consider is that, it also depends upon the dimensions of an array.you gave example of 1 D array.But problem is for @ D array.
In 2D array,an array in argument acts as a pointer(compiler dependent).so a(a+0) points to 1st row and a+1 points to second row and it's first element.
And &arr gives the address of array of ints(address of last element of an array which is equivalent to base address+size of type * number of elements).
Debendra Kumar Kar said:
(Tue, Feb 7, 2012 12:58:06 PM)
Both value will be same only the scaling factor will change.
So out put will be same and the answer will be A as yes.