Answer to Question #217639 in C++ for Hemambar

Question #217639

Write a c++ program to implement the following . Assuming that a text file named first.txt contains some text written into it .write a function named vowelwords(), that reads the file first.txt and creates a new file named second.txt ,to contain only those words from the file first.txt which start the lowercase vowel (a,e,i,o,u).


1
Expert's answer
2021-07-16T01:03:53-0400
#include <fstream>
#include <string>
#include <cctype>
using namespace std;


void vowelwords()
{
    ifstream in("first.txt");
    ofstream out("second.txt");
    string w;


    while (in) {
        in >> w;
        int c = tolower(w[0]);
        if (c == 'a' || c == 'e' || c == 'i' ||
            c == 'o' || c == 'u') {
            out << w << ' ';
        }
    }
}


int main() {
    vowelwords();
}

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 the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS