Your pigLatin
function has void
for the return type, so it is not returning anything that you might write into the ofstream
:
outputFile << pigLatin(englishWord) << ' ';
Change the return type of pigLatin
to std::string
and add
return piglatinWord;
at the end of the function:
string pigLatin(string englishWord)
{
// ... implementation here
return piglatinWord;
}
Also, to make your function more clear and uniform, I would suggest you to remove cout << piglatinWord;
from the function and output the return value in the caller function:
englishWord = engWords.substr(0, location);
cout << pigLatin(englishWord);