Write a function to count the number of blank present in a text file named "OUT.TXT
#include<iostream>
#include<fstream>
#include<string>
using namespace std;
main()
{
int count=0,countsp=0;
ifstream myFile("Out.txt");
char a[40];
while(!myFile.eof())
{
myFile >> a;
//count=strlen(a);
cout<<a<<" ";
countsp++;
}
countsp--;
cout<<endl;
cout<<"\nThere are total of "<<countsp<<" Spaces in this file\n\n";
system("pause");
}
#include<iostream>
#include<fstream>
#include<string>
using namespace std;
main()
{
int count=0,countsp=0;
ifstream myFile("Out.txt");
char a[40];
while(!myFile.eof())
{
myFile >> a;
//count=strlen(a);
cout<<a<<" ";
countsp++;
}
countsp--;
cout<<endl;
cout<<"\nThere are total of "<<countsp<<" Spaces in this file\n\n";
system("pause");
}
No comments:
Post a Comment