it may be hard to follow because it is written very oddly -- instead of a string, they use vector char and manually print it, and instead of a smart isvowel tool they search by brute force through a list.
for every letter in input
for every letter in vowel
if the letter is a vowel
put it into the result once
and if it is a u or e, put it in a second time
#include <iostream>
#include <vector>
#include <string>
// Return true if character c found
// Return false if character c not found
bool isVowel(constchar c)
{
const std::string vowels = "aeiou";
return vowels.find(c) != std::string::npos;
}
int main()
{
std::string input = "Turpentine and turtles.";
std::string whale_talk;
std::string::const_iterator citer;
for (auto c : input) // range based for loop
{
if (isVowel(c)) // Teest each character of input
{
whale_talk.push_back(c); // Append the character
if (c == 'e' || c == 'u')
{
whale_talk.push_back(c); // Append the character
}
}
}
std::cout << whale_talk << std::endl; // Output the string
}