Help for Test Word

Exercise 8.5 In Scrabble each player has a set of tiles with letters on them, and

the object of the game is to use those letters to spell words. The scoring system is

complicated, but as a rough guide longer words are often worth more than shorter

words. Imagine you are given your set of tiles as a String, like "qijibo" and you are given

another String to test, like "jib". Write a function called TestWord() that takes these

two Strings and returns true if the set of tiles can be used to spell the word. You might

have more than one tile with the same letter, but you can only use each tile once.

--

Break into these steps:

1. Loop through the string of letters to find the first letter in the target word. If you find it, print that the target letter is found

2. You want to be able to remove the found letter from the string because it cannot be used twice. You cannot change a string that is in constant memory. Make a new character array and use strcpy from the parameter to the new string. Then set  the found letter to a non-letter such as *.

3. Loop through each target letter, removing the letter in the letter string when the target letter is matched. One unfound letter lets you return false. Matching the last letter lets you return true. Surround your existing loop with an outer loop to do this.

--

You could instead make use of strstr(s1, s2); or you could make use of char *strrchr(const char *str, int c)