Hi, i am trying to make a program that gets words from a txt file (strings)
and see if the words have the character the user has inputed before.
for example...
the program will ask the user to input a letter. ( the user inputs, lets say a letter 'k')
lets say the txt file contains 5 words
dog
kiss
car
airplane
kick
since only 2 words out of the list has the letter k, the program will out put "2/5 words have the letter k in the text file"
so far i have come this far.
---------------------------------------------------------------------------------------------------
#include <iostream>
#include <fstream>
#include <string>
#include <cctype>
using namespace std;
int main ()
{
ifstream infile("words.txt");
string a_word;
int total_words = 5;
int correct_letters = 0;
char c;
cout << "enter letter";
cin >> c;
while (!infile.eof())
{infile >> a_word ;
}
cout << correct_letters << "/" << total_words << "words have" <<" "<<"letter"<<" "<<c<< "in the file";
return 0;
}
-----------------------------------------------------------------------------
I have no clue what my next step is.