作业一 指针对数组的遍历
各种++
int main(){
void test(int *p);
int a[3]={1,2,3};
printf("%p\n",a);
printf("%p\n",&a[0]);
printf("%lu\n",sizeof(a));
printf("%lu\n",sizeof(a[0]));
test(a);
}
void test(int *p){
printf("a address =%p\n",p);
printf("*p a[0] =%p\n",*p);
printf("*(p+1) a[1]=%p\n",*(p+1));
printf("*(p++) =%p\n",*(p++));
printf("*(++p) =%p\n",*(++p));
printf("++(*p) =%p\n",++(*p));
printf("p+1 =%p\n",p+1);
printf("++p =%p\n",++p);
printf("sizeof(p) =%lu\n",sizeof(p));
}
通过指针可以在形参中改变主函数中实参的值
通过指针可以返回多个值
随着每次的自增或自减 p在变化