sahajjain01

Count no. of words in a text file.

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