在数组中寻找目标值,为什么调试成功后什么都没有返回呀
#include"stdio.h"#define NOT_FOUND -1
int found(const int arr[],int target,int n);
int
main(void)
{
int x[5]={2,6,9,7,100};
int goal=7;
int size=5;
int result;
result=found(x,7,5);
printf("结果是%d\n",result);
return 0;
}
int
found(const int arr[],int target,int n)
{
int i;
int found;
found=0;
int where;
i=0;
while (!found&&i<n)
{
if (arr[i]==target)
{
found=1;
}
else
{
found=0;
}
}
if (found)
{
where=i;
}else
{
where=NOT_FOUND;
}
return (where);
}