My program is crahing, and honestly i am confused (c++)

Not likely to be your crash, but this code is terrible:

if (fnameFile.is_open())
{
    while (fnameFile.eof() == false)
    {
        plFname.resize(numFnames);
        getline(fnameFile,line);
        numFnames += 1;
    }
    fnameFile.close();
}

It doesn’t check for end of file correctly, because end of file happens during getline, not before. And the line variable goes nowhere. Try

while (getline(fnameFile,line)) plFnames.push_back(line);
fnameFile.close();

Leave a Comment