string filename, guard_name;
int call_number;
vector <Seniority> SeniorityList;
ifstream SeniorityFile;
cout << "\nWhat is the name of the seniority list that you will load into the\nprogram? (i.e. senioritylist.csv)" << endl;
getline(cin,filename);
SeniorityFile.open(filename);
while (getline(SeniorityFile, call_number, ','))
{
getline(SeniorityFile, guard_name, ',');
Seniority new_guard(call_number, guard_name);
SeniorityList.push_back(new_guard);
}
SeniorityFile.close();
return SeniorityList;
However, when I compile the code, I get the following error message on the line with the while loop.
The program will be reading in a .csv file, so I need my program to be able to deal with values separated by commas. Is there a reason why it will not accept that conditional statement?
There are two versions of "getline()". One of them is associated with the string header file and that takes an input stream, a string and then a delimiting character. The other is a member function of the std::istream class; this takes a char array, then a streamsize and an optional delimiting character. Neither one takes an input stream, an integer and then a delimiter.
Also you aren't even trying to store the data your reading in.