my out put file comes out like 0105000011500970099001120011600108001 and so on for a while. any one help me figure out wat is wrong with my code.
oh yea and what is in the input file is
it-is a-CaPital Mistake tO-theorize Before-one has DatA123.
#include <iostream>
#include <iomanip>
#include <fstream>
#include <cstdlib>
#include <cctype>
using namespace std;
void editFile(ifstream& infile, ofstream& outfile);
int main()
{
ifstream infile;
ofstream outfile;
cout << "Editing file will now begin.\n";
//textin file
infile.open("textin.dat");
if (infile.fail())
{
cout << "Input file has failed to open, now exiting.\n";
system("pause");
exit(1);
}
//textout file
outfile.open("textout.dat");
if (outfile.fail())
{
cout << "Output file has failed to open, now exiting.\n";
exit(1);
}
editFile(infile, outfile);
infile.close( );
outfile.close( );
cout << "Editing file will now end.\n";
system("pause");
return 0;
}
void editFile(ifstream& infile, ofstream& outfile)
{
int countAlpha = 0;
int countSpace = 0;
while (! infile.eof())
{
char ch;
infile.get(ch);
//Change dashes to spaces.
if (ch == '-');
{
outfile << (ch == ' ');
countSpace = countSpace + 1;
}
//Change all characters to lowercase.
if(isalpha(ch))
{
outfile << (tolower(ch));
countAlpha = countAlpha + 1;
}
//Change digits to * (asterisks)
if (isdigit(ch));
{
outfile << (ch == '*');
}
infile.get(ch);
}
cout <<"The amount of spaces written to the output file is "<<countSpace<<endl;
cout <<"The amount of alphabetic characters written to the output file is "<<countAlpha<<endl;
}