I need to print hex and decimal values in my console. I used the following piece of code to do it.
std::stringstream ss;
ss << "0x" << std::uppercase << std::hex << 15;
std::cout << ss.str() << std::endl;
ss.str("");
ss.clear();
ss << 15;
std::cout << ss.str() << std::endl;
But I am getting both values in Hex format. How to reset stringstream?
Format flags are sticky.
You can save the old format flags to restore them later: