c - Why the following code prints 1 as output? -



c - Why the following code prints 1 as output? -

difference of pointer gives 1 output..

#include<string.h> #include<stdio.h> int main() { int a=5,b=10; int *p=&a,*q=&b; int c=p-q; printf("%d",c); homecoming 0; }

subtracting 2 pointers not pointing same array create no sense.

c11: 6.5.6 additive operators (p8)

[...] if both pointer operand , result point elements of same array object, or 1 past lastly element of array object, evaluation shall not produce overflow; otherwise, behavior undefined.

c pointers

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -