此代码找到五个数字的最小数字。 我想返回(整数类型)min_value的地址,但是遇到运行时错误,分段错误 我该如何解决这个错误?
#pragma warning(disable:4996)
#include <stdio.h>
int min(int ar[]);
int main() {
int array[5];
int min_address = 0, min_value = 0;
int* Np, * Np1;
Np1 = &min_value;
for (Np = array; Np < array + 5; Np++) {
scanf("%d", Np);
}
min_address = min(array);
Np1 = (int*)min_address;
printf("%d", *Np1);
Np1++;
printf("%d", *Np1);
return 0;
}
int min(int ar[]) {
`enter code here`
int* p = ar;
int min, minidx = 0;
min = *p;
int i = 0, address;
for (p = ar; p < ar + 5; p++, i++) {
if (*p == 0) break;
enter code here
if (min > * p) {
min = *p;
minidx = i;
}
}
address = ar + minidx;
return address;
}