How to write a C++ Program to read content from a text file out.txt, count and display the number of alphabets present in it in C++ Programming.
C++ Program to read content from a text file out.txt, count and display the number of alphabets present in it |
Soulution:
//Program to read content from a text file out.txt, count and display the number of alphabets present in it.
#include<iostream.h>
#include<conio.h>
#include<fstream.h>
void main()
{
clrscr();
char a;
int count=0;
ifstream ifile("out.txt");
while(!ifile.eof())
{
ifile.get(a);
if((a>=65 && a<=90)||(a>=97&&a<=122))
{
count++;
cout<<a;
}
}
cout<<endl<<"Number of aplhabets in the file out.txt: "<<count;
getch();
}
This C++ Program to read content from a text file out.txt, count and display the number of alphabets present in it in C++ Programming.