I have some confusion about the use of std::getline function. see the following code:
#include <sstream>
#include <string>
std::ifstream ifs(filename);
std::string line;
while (std::getline(ifs, line))
{
//...//
}
for ( std::string s; getline(ifs, s)){
//...//
}
For both of the while loop and the for loop, it seems like each time in a new iteration, the "geline" is reading a new line, e.g. if we have a file storing:
1 2
3 4
5 6
then in the first iteration, getline reads 1 2
, then 3 4
in the next iteration... so, how does it know from which line it should start reading when an iteration starts?