int main()
{
int a[5]={1,2,3,4,5};
printf(%d,a[4]-a[0])
}
why it show 4 not 16?
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
Pointer incrementation and subtraction are done in terms of memory blocks
and not addresses of memory.
For example,
int *p;
p++;
The pointer here jumps to the next integer location and not the next address
in memory.
Similarly,pointer subtraction will give the difference in indexes and not
the
i didn't tried it .. but it might be internal conversion only , like
whenever we do +1 to the address of int it automatically convert it
into +4(i.e int size)
On Fri, Aug 12, 2011 at 11:34 AM, rohit rajuljain...@gmail.com wrote:
int main()
{
int a[5]={1,2,3,4,5};
printf(%d,a[4]-a[0])
}
4*(sizeof(int *))
Thank you,
Siddharam
On Fri, Aug 12, 2011 at 11:56 AM, Varun Jakhoria varunjakho...@gmail.comwrote:
i didn't tried it .. but it might be internal conversion only , like
whenever we do +1 to the address of int it automatically convert it
into +4(i.e int size)
On Fri, Aug
On Fri, Aug 12, 2011 at 11:55 AM, Avinash Dharan avinashdha...@gmail.comwrote:
Pointer incrementation and subtraction are done in terms of memory blocks
and not addresses of memory.
For example,
int *p;
p++;
The pointer here jumps to the next integer location and not the next
address in