Code:
/************************/
/**** GetEntries ****/
/************************/
void Phonebook::GetEntries(fstream &fFile)
{
int i=0;
string test1;
if(getline(fFile,test1,'|')==NULL)
{
return;
}
else
{
while(getline(fFile,vEntries[i].name,'|') != NULL) //ERROR
{
i++;
getline(fFile,vEntries[i].cnumber,'|');
getline(fFile,vEntries[i].hnumber,'|');
getline(fFile,vEntries[i].address);
}
}
}
The above code is suppose to take a .txt file and read in strings and set them to variables...Yes, for testing, I made sure there was a text file to open before actually trying it.
It seems that when I get to the while loop with getline... this is when the program decides to quit and send a stupid windows error report. I know for a fact that it gets to the while loop because just to test it, I set up an if-conditional statement right before the while loop just to output a simple string "yep" and cin.get(); After pressing enter, the program crashes, obviously from the while loop? What could be wrong with it?