How to write a C++ Program to count number of blanks present in a text file in C++ Programming.
C++ Program to count number of blanks present in a text file |
//Program to count number of blanks present in a text file.
#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==32)
count++;
}
cout<<endl<<"Number of blanks in the file out.txt: "<<count;
getch();
}
This C++ Program to count number of blanks present in a text file.