Suppose I have a struct like this:
struct Person
{
string fName;
string lName;
int age;
};
And I want to read in a file(ppl.log) like this:
Glenallen Mixon 14
Bobson Dugnutt 41
Tim Sandaele 11
How would I read in the file and store them? This is what I have
int main()
{
Person p1, p2, p3;
ifstream fin;
fin.open("ppl.log");
fin >> p1;
fin >> p2;
fin >> p3;
return 0;
}
Does that read in the entire line? Or do I have to use the getline()?