Day.01.08 指针的四则运算和遍历

#include 

void yunsuan (int a,int b,int *jia,int *jian,int *cheng,int *chu){
*jia = a +b;
*jian = a -b;
*cheng = a * b;
*chu = a / b;
}
int main (){
int a = 33,b = 10;
int jia = 0, jian = 0 , cheng = 0, chu = 0;
yunsuan (a,b, &jia, &jian, &cheng, &chu);
printf ("a+b=%d a-b=%d a*b=%d a/b=%d/n",jia,jian,cheng,chu);


数组和指针的遍历
int a [4] = {78,3,8,26};
int *c = a;//指针指向一个数组的时候,实际上指向的是数组中的第一个元素(下标为0的元素)
for (int i = 0;i < 4;i++){
printf ("%d ",*(c+i));//属于指针偏移
}


return 0;
}

你可能感兴趣的:(Day.01.08 指针的四则运算和遍历)