0

can someone help me figure out what's wrong with this piece of code? I keep getting this error Control may reach end of non-void function. I can avoid this compilation error by adding a return value (true or false) after the for loop, but then I'll be forcing the function to return true/false and then the whole loop is useless! I did get this error before as well and I just can't wrap my head around it! Thanks :)

Code

2

To the compiler, it is possible that all of the if conditions could be false and none of the returns would ever execute. So, it's not happy. (Also, I believe this is a warning, but all warnings are treated as errors due to a compiler flag.)

Simple fix. Uncomment the last return and change it to false, not true. You want it false because if the code ever drops through, you want to return false. The only time you should return true is if you actually confirm that you find a word.

If this answers your question, please click on the check mark to accept the answer. Let's keep up on forum housekeeping. ;-)

| improve this answer | |
  • Great, yeah it did work thanks :) – Askar Oct 23 '15 at 21:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .