Function to count and display the number of alphabets present in a text file
#include <iostream.h>#include <fstream.h>
#include <ctype.h>
#include <conio.h>
void display()
{
ifstream afile;
afile.open("STORY.TXT");
char ch;
int c=0;
while(afile)
{
afile.get(ch);
if (isalpha(ch))
c++;
}
cout << "The number of alphabets are " << c;
}
void main()
{
clrscr();
display();
}
step by step explanation:
1.the header file "iostream.h" is used to include the function cin and cout.2.the header file"conio.h"is used to include the function like getch and clrscr.
3.void display is also a void type function.
4.void main is also a void type function it is worked under the curley brackets.
No comments:
Post a Comment