指针问题
#include<stdio.h>int main()
{ void average(float *p,int n);
void searh(float (*p)[4],float n);
float score[3][4]={65,67,70,60,80,87,90,81,90,99,100,98};
average(*score,12);
searh(score,2);
return 0;
}
void average(float *p,int n)
{float *p_end;
float sum=0,aver;
p_end=p+n-1;
for(;p<=p_end;p++)//此处,指针变量从首地址开始访问,为什么我加上p=&score[0][0]就是错的?for(p=score[0][0];p<=p_end;p++)
sum=sum+(*p);
aver=sum/n;
printf("%f",aver);
}
void searh(float (*p)[4],float n)
{
int i;
for(i=0;i<4;i++)
{
printf("%f",*(*(p+n)+i));
}
}
问题已做标注,求大神解释