Oh. You're passing a string literal as the delimiter, but it should be a char:
Code:
if (!getline(datafile, receive, ','))
Originally Posted by
William Putnam
Also, the using namespace std is part of a package header file provided by my university's CS department for assignments.
Ah, then you should keep in mind that whoever wrote this is not familiar with C++ good practices.
EDIT:
Actually, come to think of it, you should replace the controlled infinite loop with a while loop:
Code:
while (getline(datafile, receive, ',')) {
data.insert(receive);
}
Originally Posted by
William Putnam
And I appreciated the advice on the parameters for the function, but I have the variables being declared a certain way, and this configuration works fine for me. But thanks for the pointers, I will use those in future programs.
Yeah, because as your programs get bigger and more complex, you will probably find that having your variables in a smaller scope where appropriate makes it easier to reason about your programs, and hence you will write fewer bugs and have an easier time debugging.