I'm 5 weeks into my first C++ class. I'm curious about how this code could be improved, more streamlined or simply things that I could/should have done better. The project was:Read from a .txt file that has different words on separate lines.   Determine how many vowels each word has, and print each word AND vowel count to the console. You must write and use a function outside of main(). Here's the code I wrote: #include <iostream>#include <string>#include <fstream>using namespace std;//prototypesvoid readFile();void printWords(string);int main(){    readFile();    return 0;}//end mainvoid readFile(){    ifstream inFile;    string words;    inFile.open(words.txt);    while(!inFile.eof())    {        inFile>>words;        printWords(words);    }//end while loop    inFile.close();}//end readFile functionvoid printWords(string str){    char a = 'a', e = 'e', z = 'i', o ='o', u ='u';    int num_A = 0, num_E = 0, num_I = 0, num_O = 0, num_U = 0;    cout<< str <<endl;    for(int i = 0; i < str.length(); ++i)    {        if(str.at(i) == a)        {            num_A++;        }        if(str.at(i) == e)        {            num_E++;        }        if(str.at(i) == z)        {            num_I++;        }        if(str.at(i) == o)        {            num_O++;        }        if(str.at(i) == u)        {            num_U++;        }    }//end for loop    cout<< a:  << num_A <<endl;    cout<< e:  << num_E <<endl;    cout<< i:  << num_I <<endl;    cout<< o:  << num_O <<endl;    cout<< u:  << num_U << \n <<endl;}//end printWord functionI feel like there should be a smoother function to extract, count and return the vowels. Then a function to print. Also, I tried to use a switch statement because there were so many if statements, but I couldn't get it to work.
Determining the number of vowels in each word from a file
c++;beginner;strings;file