sahajjain01

Count no. of alphabets in a file.

Jul 20th, 2014
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.51 KB | None | 0 0
  1. //Program to read content from a text file out.txt, count and display the number of alphabets present in it.
  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>=65 && a<=90)||(a>=97&&a<=122))
  17.         {
  18.             count++;
  19.             cout<<a;
  20.         }
  21.     }
  22.     cout<<endl<<"Number of aplhabets in the file out.txt: "<<count;
  23.     getch();
  24. }
Advertisement
Add Comment
Please, Sign In to add comment