Small digression: professor is a she not a he.
I think I need a little more explanation, here is my understanding of what is happening here. Maybe you or anyone else, can point out the wholes in my logic?
Breaking down the code into smaller sections with my out look on it.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
in.get(foo, MAX_CHAR, ';');
while (!in.eof())
{
in.get(); //remove field seperator ';'
in.get(bar, MAX_CHAR, '\n');
in.ignore(100, '\n'); //remove record seperator '\n'
anEntry.setFoo(foo);
anEntry.setBar(bar);
addEntry(anEntry);
in.get(foo, MAX_CHAR, ';'); //start the next record
}
in.close();
|
Below, This is saying: get char until, MAX_CHAR(100 in this case), OR you hit a semi colon.
|
in.get(foo, MAX_CHAR, ';');
|
so this (I am assuming) is taking
foo;
and storing it into foo.
then a while loop happens that runs while eof is not true.
while (!in.eof())
The above two statements make the least sense to me. As in I do not understand the logic.
Then the code goes on to gobble up the remaining ";"
|
in.get(); //remove field seperator ';'
|
Then
its reading the rest of the line up to the new line char
in.get(bar, MAX_CHAR, '\n');
setters -- applying the data to variables.
1 2
|
anEntry.setFoo(foo);
anEntry.setBar(bar);
|
adding -- data to file
says its starting a new record - but I am not understanding how...
the creates a "new record "
|
in.get(foo, MAX_CHAR, ';'); //start the next record
|
and over all I just don't understand what is happening systematically. based on this above code and how to apply that understanding to modify this code to read
1 2
|
foo;bar;foobar
foo;bar;foobar
|
can some one walk me through this. I really want to understand.