I wrote a small program that counts words, and looks for specific words, but the problem is that it's case-sensitive.
So if the search requested "one" and the file contains "ONE" the count for "one" would register as 0.
Code:
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
using namespace std;
int main(){
ifstream countwords;
string word, specificword;
int counter = 0, checkword = 0;
cout<<"Type the word you want to count in the file.\n";
cin>>specificword;
cin.ignore();
countwords.open( "wordcount.txt" );
while ( countwords>>word ){
if ( word == specificword ){
checkword++;
}
counter++;
}
countwords.close();
cout<<"\n\nThe file contains "<<counter<<" words.\n";
cout<<checkword<<" of them is "<<specificword<<".\n\n";
cin.get();
}