I wrote a function to retrieve text from a text file and fill out a structure, which will eventually be used to fill out a vector. The text file contains an unknown number of members that I am trying to load. The function works for the first instance. However, the second time the function is called, I get a few lines from the first entry, and then my error checks tells me that it is not reading the second entry correctly.
void FillContact(ifstream &in_stream, Client &TempMarket)
{
// a bunch of getlines with strings stored in class members of TempMarket
}
int main ()
{
ifstream in_stream;
in_stream.open("infile.dat");
while (!in_stream.eof)
{
FillContact(in_stream, TempMarket)
}
}
The program compiles fine. I think the error lies in attempting to pass by reference to the same function multiple times. Has anyone else encountered such a problem before and how did they fix it? Should I be using pointers instead?