sahajjain01

Count no. of blanks in a file.

Jul 20th, 2014
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. //Program to count number of blanks present 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;
  11.     int count=0;
  12.     ifstream ifile("out.txt");
  13.     while(!ifile.eof())
  14.     {
  15.         ifile.get(a);
  16.         if(a==32)
  17.         count++;
  18.     }
  19.     cout<<endl<<"Number of blanks in the file out.txt: "<<count;
  20.     getch();
  21. }
Advertisement
Add Comment
Please, Sign In to add comment