今天学习了数组指针,拿来练练手~~~
- #include <stdio.h>
- int main(int argc, const char * argv[]) {
- // 定义数组
- int num[]={1,4,6,8,10};
- //定义指针
- int *p=num;
- int *q=&num[4];
- printf("*p=%d,地址为%p\n",*p,p);
- printf("*q=%d,地址为%p\n",*q,q);
- printf("q-p的结果是%ld\n",q-p);
- printf("p-q的结果是%ld\n",p-q);
- return 0;
- }
复制代码
|
|