I need some help to do the following
Count all spaces written to the output file
Count all alphabetic characters in the output file

include "stdafx.h"
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
 
int main () 
{
string line;
ifstream myfile ("checkIn.dat");
if (myfile.is_open())
{
while (! myfile.eof() )
{
getline (myfile,line);
cout << line << endl;
}
myfile.close();
}
 
else cout << "Unable to open file"; 
 
return 0;
}

I need some help to do the following
Count all spaces written to the output file
Count all alphabetic characters in the output file

include "stdafx.h"
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
 
int main () 
{
string line;
ifstream myfile ("checkIn.dat");
if (myfile.is_open())
{
while (! myfile.eof() )
{
getline (myfile,line);
cout << line << endl;
}
myfile.close();
}
 
else cout << "Unable to open file"; 
 
return 0;
}

You can include ctype.h and it has functions isspace and isalpha which will help you ...and you need to extract character by character.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.