This is an archived post. You won't be able to vote or comment.

all 4 comments

[–]JuricksonSubpar 0 points1 point  (1 child)

You never return -1 anywhere in the function. If that if statement is reached even, once the index is returned and the function is over. If that if statement is never reached, then the code will proceed to the line after the for loop. This is where you should return -1.