How to count number of times for the appearance of word "do" in C++ Programming ?
Count the number of occurrences of a word |
//Program to count number of times for the appearance of word "do".
#include<conio.h>
#include<ctype.h>
#include<string.h>
void main()
{
clrscr();
int count=0;
char a[10];
ofstream ofile("file.txt");
ofile<<"do re me fa so la ti do do re me fa so la ti do do re me fa so la ti do";
ofile.close();
ifstream ifile("file.txt");
while(!ifile.eof())
{
ifile>>a;
if(strcmp(a,"do")==0)
count++;
}
cout<<count;
getch();
}
This C++ Program is: To count number of times for the appearance of word "do".