//programe to count the occurance of the word 'do'
#include<fstream.h>
#include<conio.h>
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
void countdo();
void main()
{ clrscr();
countdo();
getch();
}
void countdo()
{ char str[50], arr[10];
int i=0;
fstream f1("memo.txt",ios::in);
if (!f1)
{ cout<<"\n could not find";
getch();
exit(-1);
}
char ch;
cout<<"\n THE SENTENCE IS : ";
while (!f1.eof())
{ f1.get(ch);
cout<<ch;
}
f1.close();
fstream f("memo.txt",ios::in);
while (!f.eof())
{ f>>arr;
if (strcmp (arr,"do")==0)
i++;
}
f.close();
cout<<"\n 'do' occured "<<i<<" times";
return;
}
#include<fstream.h>
#include<conio.h>
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
void countdo();
void main()
{ clrscr();
countdo();
getch();
}
void countdo()
{ char str[50], arr[10];
int i=0;
fstream f1("memo.txt",ios::in);
if (!f1)
{ cout<<"\n could not find";
getch();
exit(-1);
}
char ch;
cout<<"\n THE SENTENCE IS : ";
while (!f1.eof())
{ f1.get(ch);
cout<<ch;
}
f1.close();
fstream f("memo.txt",ios::in);
while (!f.eof())
{ f>>arr;
if (strcmp (arr,"do")==0)
i++;
}
f.close();
cout<<"\n 'do' occured "<<i<<" times";
return;
}
0 comments:
Post a Comment