Disclaimer: This is a little bit of my experience, I hope it will be helpful to everyone.
void minmax(int a[],int len,int *min,int *max)
{int i;
*min=*max=a[0];
for(i=1;i<len;i++)
{
if(a[i]<*min)
{*min=a[i];}
if(a[i]>*max)
{*max=a[i];}
}
}
int main()
{
int a[]={1,2,3,6,7,11,5,16,9,10};
int min,max;
minmax(a,sizeof(a)/sizeof(a[0]),&min,&max);
printf("min=%d,max=%d\n",min,max);
return 0;
}
1. The array in the table in the function parameter is actually a pointer
2.sizeof(a)==sizeof(int *)
3. But you can use the array operator [] to operate
The following four function prototypes are equivalent
int sum (int * ar, int n);
int sum (int *, int);
int sum (int ar [], int n);
int sum(int [],int);
Note: Suppose int b[]; can be seen as int *const b;
b[]=a; Wrong ; Array variables cannot be assigned, and array variables can be regarded as const pointers and cannot be assigned.