Write function definition for SUCCESS( ) in C++ to read the content of a text file STORY.TXT, count the presence of word STORY and display the number of occurrence of this word.
Note :
– The word STORY should be an independent word
– Ignore type cases (i.e. lower/upper case)
Example :
If the content of the file STORY.TXT is as follows:
Success shows others that we can do it. It is
possible to achieve success with hard work. Lot
of money does not mean SUCCESS.
The function SUCCESS () should display the following:
3
void SUCCESS()
{
int count=0;
ifstream f('STORY.TXT');
char s[20];
while (!f.eof())
{
f>>s;
if(strcmpi(s,'STORY')==0){
count++;
}
cout<<count;
f.close();
}
}