iostream - Meaning of trailing stream manipulator in C++ expression -
what difference between both expressions of each pair ? don't understand effect of trailing std::dec @ end of expressions.
with cin, between :
int i; std::cin >> std::hex >> >> std::dec; and :
int i; std::cin >> std::hex >> i; same question cout, between :
int i; std::cout << std::hex << << std::dec << std::endl; and :
int i; std::cout << std::hex << << std::endl; thanks !
some flags set manipulators active next output or input operation.
others, formatting flags set std::hex or std::dec set permanently in stream object, , affects output , input operations after setting flag.
so if use std::hex integer output , input point in hexadecimal notation. if want output or input single number in hexadecimal need "reset" default decimal notation using e.g. std::dec leading statements like
std::cin >> std::hex >> >> std::dec;
Comments
Post a Comment