What is difference between while(getline()) & while(!getline().eof()) ?
Am parsing an input string. I have tried with both condition check and I see the difference in result.
std::string testStr = "CN=Test, OU=XYZ, O=ABC";
std::stringstream inpStrStream(testStr);
std::string tempStr;
getline(inpStrStream, tempStr, '=');
std::cout<<"Hello:"<<tempStr<<std::endl;
//Let's call this as "Ex A"
while(getline(inpStrStream, tempStr, '='))
{
std::cout<<tempStr<<std::endl;
}
(OR)
//Let's call this as "Ex B"
while(!getline(inpStrStream, tempStr, '=').eof())
{
std::cout<<tempStr<<std::endl;
}
I expected same result in both but the result for "Ex A" & "Ex B" are different. I don't see string "ABC" in output of "Ex B":
Ex A result: Hello:CN Test, OU XYZ, O ABC
Ex B result: Hello:CN Test, OU XYZ, O