Can someone tell me why this won't count the * symbol? The program is done except for that.
CODE
#include <ctype.h>
#include <stdio.h>
#include <fstream>
#include <iostream>
#include <cstdlib>
using namespace std;
void add_plus_plus(ifstream& in_stream, ofstream& out_stream);
int main( )
{
ifstream fin;
ofstream fout;
char ch;
int count = 0;
int isalpha;
int isspace;
cout << "Begin editing files.\n";
fin.open("E:\\textin.txt");
if (fin.fail( ))
{
cout << "Input file opening failed.\n";
system ("pause");
exit(1);
}
fout.open("E:\\textOut.txt");
if (fout.fail( ))
{
cout << "Output file opening failed.\n";
system ("pause");
exit(1);
}
add_plus_plus(fin, fout);
fin.close( );
fout.close( );
cout << "End of editing files.\n";
system ("pause");
}
void add_plus_plus(ifstream& in_stream, ofstream& out_stream)
{
char next, ch;
int isalpha = 0;
int isspace = 0;
in_stream.get(next);
while (!in_stream.eof( ))
{
if (next == '-')
ch = ' ';
else if (isupper(next))
ch = tolower(next);
else if (isdigit(next))
ch = '*';
else ch = next;
out_stream << ch;
if (next == ch)
isalpha++;
if (next == ('.'))
isspace++;
if (next == ('*'))
isspace++;
if (next == (' '))
isspace++;
in_stream.get(next);
}
cout << "\nNumber of letters: " << isalpha <<endl;
cout << "Number of spaces: " << isspace <<endl;
}
Thanks,
Everybody