qfedu-c-level/day9/d9.c

15 lines
286 B
C
Raw Permalink Normal View History

2023-07-13 19:18:49 +08:00
#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;
}