Data File Handling Solution (SD/4/B/121)

Write a function in C++ to count the no. of "He" or "She" words present in a text file "STORY.TXT".


Solution of 

Data File Handling - Text File (SD/4/B/121)



void countHeShe( )
{
ifstream fin("STORY.TXT",ios::in);
char word[20];
int count=0;
while(!fin.eof())
{
fin.getline(word,20,' ');
if(strcmpi(word,"he")==0 || strcmpi(word,"she")==0)
count++;
}
cout<<"The count of He/ She in File is : "<<count<<" times.\n";
}




No comments

Post your comments

Powered by Blogger.