65 792
Assignments Done
99,4%
Successfully Done
In October 2018

Answer to Question #73214 in C++ for Nikesh Hembrom

Question #73214
write a function named vowel_words() which will segregate the words starting with vowels from the "first_file.txt"
Expert's answer
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
using namespace std;


void vowel_words()
{
ifstream in("first_file.txt");
if(!in.is_open())
{
cout << "Can't open file\n";
exit(0);
}
vector<string> vwords;

while(true)
{
string word;
getline(in, word, ' ');

if(!in) break;

char f;
if(!word.empty())
f = word.front();
if(f == 'a' || f == 'e' || f == 'i' || f == 'o' || f == 'y' || f == 'u'
|| f == 'A' || f == 'E' || f == 'I' || f == 'O' || f == 'Y' || f == 'U')
vwords.push_back(std::move(word));

}

for(const auto& x : vwords)
cout << x << endl;
}



int main()
{
vowel_words();
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions