一个指针问题,
gcc编译一直报错findtwolarge.c:29: warning: passing argument 1 of ‘find_two_largest’ makes pointer from integer without a cast,说是29行,可没看出哪里的问题
代码如下,请高手指点下,代码作用是求一个数组最大和第二大两个数
#include <stdio.h>
void find_two_largest(int a[], int n, int *largest, int *second_largest)
{
int i;
*largest = *second_largest = a[0];
for (i = 1; i < n; i++)
{
if (*largest > a[i]){
*largest = a[i - 1];
*second_largest = a[i];
} else if (*second_largest < a[i]) {
*largest = a[i];
*second_largest = a[i - 1];
}
}
}
int main(void)
{
int i;
//printf("How many number do you want? --: ");
//scanf("%d", &n);
int a[5], l, sl;
for (i = 0; i < 5; i++)
scanf("%d", &a[i]);
find_two_largest(a[5], 5, &l, &sl);
printf("Largest: %d\n", l);
printf("Second largest: %d\n", sl);
return 0;
}