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
Post a Comment