0

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 with a lowercase vowel (i.e., with 'a', 'e', 'i', 'o', 'u').
For example, if the file FIRST.TXT contains
Carry umbrella and overcoat when it rains
Then the file SECOND.TXT shall contain
umbrella and overcoat it .. IT AN URGENT!!!!!!!!!!!!!!!!!!

3
Contributors
2
Replies
16
Views
3 Years
Discussion Span
Last Post by Lucaci Andrew
0

Daniweb is not a homework service. We expect you to write the code you need, but will assist with specific problems or questions you might have.

-1

Here's a headstart. Regex to find words starting with a lowercase vowel.

#include <iostream>
#include <regex>
#include <string>
using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
    regex reg("\\b[aeiou]\\S*");
    string str("Carry umbrella and overcoat when it rains");
    smatch match;

    while (regex_search(str, match, reg))
    {
        for (auto i : match)
            cout << i << endl;
        str = match.suffix().str();
    }

    return 0;
}

Here's the reference link:
regex
regex_search

Edited by Lucaci Andrew

Votes + Comments
Stop feeding them fish, and teach them how to fish!
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.