qfedu-c-level/day9/d9.c

15 lines
286 B
C

#include <stdio.h>
int main()
{
int arr[10];
for (int i = 0; i < 10; i++)
{
printf("%d addr %p\n", i, &arr[i]);
}
int *p = arr, *q = p + 2;
int n = q - p; // 计算两个指针之间的元素个数
printf("%p - %p = %d\n", q, p, n);
return 0;
}