sahajjain01

Count no. of word 'the' in a file.

Jul 22nd, 2014
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. //Program to count number of times the word 'the' as an independant word in a text file.
  2. //out.txt:-"The C++ is a the general purpose the programmingthe language."
  3. #include<iostream.h>
  4. #include<conio.h>
  5. #include<fstream.h>
  6. #include<string.h>
  7. void main()
  8. {
  9.     clrscr();
  10.  
  11.     char a[80];
  12.     int count=0;
  13.     ifstream ifile("out.txt");
  14.     while(!ifile.eof())
  15.     {
  16.         ifile>>a;
  17.         if((strcmp(a,"the")==0)||(strcmp(a,"The")==0));
  18.         count++;
  19.     }
  20.     cout<<endl<<"Number of 'the' in the file out.txt: "<<count;
  21.     getch();
  22. }
Advertisement
Add Comment
Please, Sign In to add comment