Linked Questions

Popular Questions

Resetting std::stringstream format flags

Asked by At

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?

Related Questions