I am trying to read data from an ifstream. I am using code as a reference that my prof gave me. I am confused as to what the for(;;) is doing and when the loop ends. I understand for loop basics but I have never seen this notation before.
//------------------------------- buildTree ----------------------------------
// To build a tree, read strings from a line, terminating when "$$" is
// encountered. Since there is some work to do before the actual insert that is
// specific to the client problem, it's best that building a tree is not a
// member function. It's a global function.
void buildTree(BinTree& T, ifstream& infile) {
string s;
for (;;) {
infile >> s;
cout << s << ' ';
if (s == "$$") break; // at end of one line
if (infile.eof()) break; // no more lines of data
NodeData* ptr = new NodeData(s); // NodeData constructor takes string
// would do a setData if there were more than a string
bool success = T.insert(ptr);
if (!success)
delete ptr; // duplicate case, not inserted
}
}