Write a function
int findLast(string words[], int numWords, string target)
that returns the index of the last occurence of target in words or -1 if there is no occurrence.
Remember: you can compare string objects using ==, these are NOT C-strings !
Here is my solution:
int findLast(string words[], int numWords, string target)
{
for(int i = 0; i >= numWords; i--)
{
if(words[i] == target)
{
return i;
}
}
return -1;
}
Right now, MyProgrammingLab is not accepting this answer. Is there anything I need to add or change in this function? Any help would be appreciated.