In the whole, you got it, but your code is very complicated.
Firstly, you should tell us which rules you’re complying with, since it doesn’t seem you need to manage special cases like ‘y’ or apostrophe (as you do).:
https://en.wikipedia.org/wiki/Pig_Latin#Rules
Anyway, your is_vowel() function can be simplified:
- if y_is_vowel is true
is ‘c’ an y or an Y ?
If so, return true.
- if y_is_vowel is false or ‘c’ is neither y nor Y, return if the result of searching ‘c’ inside VOWELS is std::string::npos or not.
- - -
Let’s have a look at your main() function.
The logic is
- argc == 1 ? Ask user for input, then exit.
- argc == 2 ? Wrong: there’s the input file, but not the output file (or you can decide to read the sentence and to output it to std::cout) - then exit.
- argc > 2 ? Ok.
Once you have performed the above check, start opening the files. Do not open them inside the for loop. As a matter of fact, you don’t need a loop at all.
- - -
To split a std::string into tokens... Please, take it easy :-)
Just initialize a std::istringstream from the ‘line’ and then output (>>) into another std::string, untill it is empty.
There are other issues, but let’s start from here.
Happy coding!