Getline as the conditional of a While loop

I am trying to use getline as the conditional for a while loop as seen below.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
        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.
error C2780: 'std::basic_istream<_Elem,_Traits> &std::getline(std::basic_istream<_Elem,_Traits>&,std::basic_string<_Elem,_Traits,_Alloc> &)' : expects 2 arguments - 3 provided


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?
Getline works on strings not ints. Try something like
1
2
 char delim;
while (Seniorityfile >> call_number >> delim)
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.
Thanks for the help naraku, that is a good solution!
Topic archived. No new replies allowed.