This is my code for the helper.c file. The code forms part of the 'find' program. I'm getting an error: 'expected expression' re: the last 'else' statement. I have tried removing the 'else' statement or removing the 'false' from the second 'return' but this doesn't fix it. I can't see what I'm doing wrong.
bool search(int value, int values[], int n)
{
if (n>=0)
{
for (int i=0; i<n; i++ )
{
if (values[i] == value)
{
return true;
}
else
{
return false;
}
}
else
{
return false;
}
}
}
After advice I've changed lower part to this:
else if ((values[i] != value) && (i = n-1))
{
return false;
}
}
return 0;
}
}
Now I'm getting one error which is:
control may reach end of non-void function
}
^
////////////
Third attempt, was successful.
bool search(int value, int values[], int n)
{
if (n >= 0)
{
for (int i=0; i<n; i++)
{
if (values[i] == value)
{
return true;
}
}
}
return false;
}