Address difference between two integer variables in c

前端 未结 5 1236
醉梦人生
醉梦人生 2021-01-07 07:17
#include 
int main()
{
    int i=10,j=20,diff;
    diff=&j-&i;
    printf(\"\\nAddress of i=%u Address of j=%u\",&i,&j);
    printf(\"         


        
5条回答
  •  孤独总比滥情好
    2021-01-07 07:26

    Computing the difference between pointers that do not point into the same array (as in your case) is undefined behavior in C. See this for more information and references.

提交回复
热议问题