sahajjain01

Count no. of word "do".

May 8th, 2014
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.47 KB | None | 0 0
  1. //Program to count number of times for the appearance of word "do".
  2. #include<fstream.h>
  3. #include<conio.h>
  4. #include<ctype.h>
  5. #include<string.h>
  6. void main()
  7. {
  8.     clrscr();
  9.     int count=0;
  10.     char a[10];
  11.  
  12.     ofstream ofile("file.txt");
  13.     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";
  14.     ofile.close();
  15.  
  16.     ifstream ifile("file.txt");
  17.     while(!ifile.eof())
  18.     {
  19.         ifile>>a;
  20.         if(strcmp(a,"do")==0)
  21.         count++;
  22.     }
  23.     cout<<count;
  24.     getch();
  25. }
Advertisement
Add Comment
Please, Sign In to add comment