#include <iostream>
#include <fstream>
//#include <cstring>
//#include <string>
using namespace std;
int main()
{
string word;
ifstream infile;
infile.open ("inputfile.txt");
if (infile.fail())
{
cout<<"UNABLE TO ACCESS INPUT FILE";
}
while(!infile.eof())
{
while (infile>> word)
{
cout<<word<<endl<<endl;
}
}
infile.close ();
system("pause");
return 0;
}
The above code couts all the words in the input text file. How do I cout just one word of my choice? I am asking this because I want to eventually be able to cin a word from user, and find that word in the input file either to delete or replace it with another word.