I have a question about using unsetf. The below is an answer for getting correct input for formatted numbers.
Actually, You can force
operator>>to get and properly interpret prefixes0and0x. All you have to do is to remove default settings forstd::cin:std::cin.unsetf(std::ios::dec); std::cin.unsetf(std::ios::hex); std::cin.unsetf(std::ios::oct);Now, when you input
0x1ayou will receive26.
I don't understand the last two unsetf commands for hex and oct. If I use the unsetf with dec only, I get the correct input, which I mean inputting 0x1a and receiving 26.
So what's the point of using unsetf for hex and dec?