I'm having trouble filtering the 'commented' lines in a text file. I want to filter the lines beginning with # or // in the text file.
Thanks!
string code, name, year, semester, value, data;
char delimiter = '|';
ifstream ifsUnits;
ifsUnits.open("./data/units.txt");
if (ifsUnits.fail())
cout << "\nError reading from file <units.txt>.";
else
{
while (!ifsUnits.eof())
{
getline(ifsUnits, data);
stringstream ssData(data);
while (ssData.good())
{
getline(ssData, code, delimiter);
getline(ssData, name, delimiter);
getline(ssData, year, delimiter);
getline(ssData, semester, delimiter);
getline(ssData, value, delimiter);
lUnits.push_back(Unit(stoi(code), name, stoi(year), stoi(semester), stoi(value)));
}
}
}
ifsUnits.close();
Text file contents:
//idNumber|name <-- i want to bypass all the lines starting with // 1001|Mary Doe 1002|John Down 1003|John Doe 1004|Marilyn Hendrix