Question: Can someone explain to me how while(getline()) works in c++? What makes the loop even start? For example, say I have an input file. ifstream

Can someone explain to me how while(getline()) works in c++? What makes the loop even start? For example, say I have an input file.

ifstream inFile;

inFile.open("input.txt");

string str;

int LENGTH = 0;

while(getline(inFile,str))

{

LENGTH++;

}

cout<

This gives the number of rows in the file. I don't understand why. Can someone explain what's going on here?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!