指针相减--仅限于同一块内存空间
作者:互联网
#include <stdio.h>
int main(void) {
int b[6] = {3,-1,-4,0,5};
printf("b[5]与b[3]相差%d个单元\n",&b[5] - &*(b+3));
return 0;
}
输出结果:
b[5]与b[3]相差2个单元
--------------------------------
Process exited after 0.01435 seconds with return value 0
请按任意键继续. . .
标签:--------------------------------,return,相减,--,内存空间,int,任意键,相差,单元 来源: https://blog.csdn.net/weixin_45846799/article/details/120251579