For loops help?

I am trying to write a program that prompts the user for a word; called SEARCH. Then begin reading words from the user, counting them until SEARCH is entered. Display how many words were entered until the SEARCH word was found. I want to use a FOR loop to do this. Any tips.
Here's one tip:

Use string objects so you can compare easily with the == operator
Last edited on
how would i do the for loop part can you give example
1
2
3
4
5
6
for(;;)
{
  cin >> wordFromUser;
  numberOfWordsEnteredSoFar++;
  if (wordFromUser == wordSearchingFor) return numberOfWordsEnteredSoFar;
}
Topic archived. No new replies allowed.