Hello to all
I have a question please. I have read that the result of comparison between pointers who point to different arrays is undefined.
For example assume tha we have :
My question is : Why the behavior is undefined ? arr1 and arr2 will have different addressed of course but my reflection is the result is not sure because compiler may give a higher address to arr1 for example 2000 and arr2 will have 1000 or something. I am right?Code:#include<stdio.h> int main(void) { int arr2[2]={2,3} , arr1[2]; int *p1 = arr1 , *p2 = arr2; printf("%d , %d" , arr1 , arr2); if( p1 < p2 ) // do sth ... UNDEFINED BEHAVIOR return 0; }
Thank you in advance