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();
}

Never Mind. The problem was that the input file had some weird characters in it.

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.