I tried to do hex conversions using std::stringstream
as the following:
std::stringstream s;
s << std::hex;
int i;
s << "100";
s >> i; // 256
s << "10"; // doesn't work
s >> i;
But it fails on subsequent conversions as the comment points out. Do I need to reset the stringstream
? Why does it fail?