error: subscript requires array or pointer type
thats my code
void main(int argc, char* argv[])
{
int s[10];
int n=10;
int location;
int x;
cout<<"enter the value you want to search for: "<<endl;
cin>>x;
for(int i;i<n;i++)
s[i]=rand()%10;
binsearch(n,s,x,location);
//return 0;
}
void binsearch(int n, int s,int x,int& location)
{
int low,high,mid;
low=1;
high=n;
location=0;
while((low<=high)&&(location==0))
{
mid=floor((low+high)/2);
if(x==s[mid])
location=mid;
else if(x<s[mid])
high=mid-1;
else
low=mid+1;
}
}
i donno whats wrong, its supposed to be workin.
thnx for help