Hey. Can someone help me with this parsing function? I'm not sure why it won't work. Whenever I test it with a valid input and output file it simply crashes.
void parse(string infilename,string outfilename)
{ string temp;
ifstream infile(infilename.c_str());
ofstream outfile(outfilename.c_str(), ofstream::app);
if(!infile)
{ cerr<<"Infile Not Working!";
}
if(!outfile)
{ cerr<<"Infile Not Working!";
}
while(infile>>temp, !infile.eof())
{
string::iterator beg=temp.begin();
string::iterator end=temp.end();
while(beg!=end)
{
if(!isalpha(*beg))
temp.erase(beg);
beg++;
}
outfile<<temp<<" ";
}
infile.close();
infile.clear();
outfile.close();
outfile.clear();
}