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;
}
2
Contributors
1
Reply
2
Views
11 Years
Discussion Span
Last Post by HackWizz
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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.