Hi, I need assistance in my homework, I wrote a code, but since I'm off campus, and i can't seem to connect to the schools VPN, therefore I can't access my code. BUT I'm pretty sure it got lots of mistakes.
My professor want us to do this:
"Write a program which reads words from
/usr/share/dict/words, into a vector of
strings, then counts how many words have a vowel [aeiou] in a given position.
A sample run should look like this:
Which letter postion? 4
137266 words in the dictionary have a vowel [aeiou] in position 4
Which letter postion? 15
3676 words in the dictionary have a vowel [aeiou] in position 15
Note: Be sure to ignore case, that is, count upper or lower case vowels.
"Position 1" means the first letter, "Position 2" means the second letter, etc."
Any sample code or instructions on how to start this off will be great. Thank You
Just read each line/word of the file and check if the queried position has a vowel, then add to the count. Once you've read all the words, output the count. Something like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
while((std::cout << "Which letter position? ") && (std::cin >> pos))
{
if(std::ifstream file {"/usr/share/dict/words"})
{
std::string word;
while(file >> word)
{
//your code here
}
//your code here
}
else
{
std::cerr << "Unable to open the dictionary" << std::endl;
}
}