I just have a quick question. while implementing linear search in pset3, why is it that when I use "return 0" instead of "return true", the search function acts weird. Like it'd sometimes only find the needle if it's in the middle of the hay or at the beginning? I'm just curious. Shouldn't "return 0" and "return true" indicate the same thing?
The problem with that is that true is 1, not 0, so return true is the same as return 1. If the return type really is bool, then you're returning the exact opposite of what you want to return.
You may be confused by this and the standard retrun values used by main and other standard functions. In many cases, they return an int, but use 0 to indicate success and non-zero values to indicate either a failure in general, or specific values to indicate specific conditions that occurred.
If this answers your question, please click the check mark to accept this and remove the question from the unanswered pool. Let's keep up on forum maintenance. ;-)