执行时出现Unhandled exception in XX.exe:0xC0000005 Access Violation 错误
请教高手~ 写了一段很简单的计算最大最小值并获得其在数组中位置的程序,编译通过后执行时出现Unhandled exception in XX.exe:0xC0000005 Access Violation 错误。 貌似是哪里越界了? 不太明白这个错误的原因,麻烦指导下~谢啦~
#include <stdio.h>
#define SIZE 10
int max_array(int num[], int numbers, int *PmaxPos);
int min_array(int num[], int numbers, int *PmaxPos);
main()
{
int a[SIZE], i,max,min, maxPos, minPos;
printf("Input 10 numbers:\n");
for (i=1; i<=SIZE; i++)
{
scanf("%d", a[i]);
}
printf("Array a is:\n");
for (i=1; i<=SIZE; i++)
{
printf("%d",a[i]);
}
max = max_array(a, SIZE, &maxPos);
min = min_array(a, SIZE, &minPos);
printf("The maximum is %d, and the minimum is %d", max, min);
}
int max_array(int num[], int numbers, int *PmaxPos)
{
int i, max;
max = num[0];
*PmaxPos = 0;
for (i=0; i<numbers; i++)
{
if(num[i]>max)
{
max=num[i];
*PmaxPos = i;
}
}
return max;
}
int min_array(int num[], int numbers, int *PminPos)
{
int i, min;
min = num[0];
*PminPos = 0;
for (i=1; i<numbers; i++)
{
if(num[i]<min)
{
min=num[i];
*PminPos = i;
}
}
return min;
}