I keep getting an error that says "No matching function to call"
I've compared it to all my other functions that I have written but it still isnt working.
I'm a beginner! I'm trying to write something that asks for a list and returns true if the list is in chronological order.
Alright, now I have fixed that & only that, but now I get an error "Control may reach end of non-void function". I don't understand what that means or how to fix that.
If s is 0, then the for loop will not run, meaning that neither of the two return statements will be executed. This, you get to the end of the function without a return statement.
Also, I think your isSorted function is implemented wrong - it returns as soon as it checks the first value, the rest of the values are never checked.
bool isSorted(int l[80], constint s, bool r)
{
for (int i = 0; i < s; i++)
{
if (l[i] < l[i+1])
returntrue;
elsereturnfalse;
}
}
If s is 0 then the for loop will never run which would result in 0 return statements. Also you have it return after the first element. What you should do is return false on the first non-sorted value found and after the entire loop if all of them are sorted (it didn't return false) then you should return true.
Try walking through the function yourself on some paper. Write down the values that you are passing and see what happens when you run it. Either that, or step through it with a debugger.