Can you think of a word in English that has the most consecutive vowels?
For example, the word "zombies" has two consecutive vowels with "ie" while the word "abstemious" has three
consecutive vowels. This is a pretty challenging
puzzle for a human but it can be solved pretty quickly by a computer. Write a program that reads this file,
bigwords.txt or on Windows use bigwords-windows.txt, which contains 87314 English words. The longest word is
13 letters (abbreviations).
Your solution should:
- Use C-strings (array of char) to read each word, not the STL string class. You may need
to include <cstring>. You can get the
length of a C-string using the strlen(s) function.
-
The easiest way to write this program is to break it up into the following parts and test each part
independently before moving on to the next part:
- In main, open the file and read every word from the file into a C-string
- A function that takes a char as input and returns true if it is a vowel, false otherwise
- A function that takes a c-string as input and returns the number of consecutive vowels in the word.
You can do this by looping through each character in the c-string. As long as the current character
is a vowel, increment a vowelCounter variable and remember the longest value for vowelCounter. If the current
character is a non-vowel, reset vowelCounter back to 0.
- Modify main to use your function on each word, remember the one with the most consecutive vowels,
and output it after the last word has been read from the file
Show your working code and what the word is with the most consecutive vowels!