These threads do NOT answer me:
resetting a stringstream
How do you clear a stringstream variable?
std::ifstream file( szFIleName_p )
Imagine a config file.
par1=11
par2=22
codes:
std::string line, strpar1, strpar2;
int par1, par2;
std::ifstream configfile("config.cfg");
std::getline(configfile, line); // first line to variable "line"
std::istringstream sline(line);
while (std::getline(sline, strpar1, '='));
par1 = std::stoi(strpar1); // par1 get 11
bool b = sline.eof(); // true
std::getline(configfile, line); // second line to variable "line"
sline.clear(); //
sline.str(line); // reuse "sline"
b = sline.good(); // true // goodbit is zero, indicating that none of the other bits is set.
b = sine.fail(); // false
b = sline.bad(); // false
b = sline.eof(); // false
while (std::getline(sline, strpar2, '='));
par2 = std::stoi(strpar2); // par2 get 22
goodbit is zero, indicating that none of the other bits is set