sahajjain01

Count no. of alphabets in a file.

May 8th, 2014
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.40 KB | None | 0 0
  1. //Program to count number of alphabets in a file.
  2. #include<fstream.h>
  3. #include<conio.h>
  4. #include<ctype.h>
  5. void main()
  6. {
  7.     clrscr();
  8.     int count=0;
  9.     char a;
  10.  
  11.     ofstream ofile("file.txt");
  12.     ofile<<"abcde34fghi43jkl34m234nop2343252qrst34uvwxyz";
  13.     ofile.close();
  14.  
  15.     ifstream ifile("file.txt");
  16.     while(!ifile.eof())
  17.     {
  18.         ifile.get(a);
  19.         if(isalpha(a))
  20.         count++;
  21.     }
  22.     cout<<count;
  23.     getch();
  24. }
Advertisement
Add Comment
Please, Sign In to add comment