No, there is no better way. A better way would be to form a custom stream manipulator like std::hex . You can then turn off and turn off the whole print without having to specify it for each number. But custom manipulators work on the thread itself, and there are no format flags to do what you want. I suppose you could write your own thread, but in this case more work than now.
Honestly, it's best to see if your text editor has functions to make it easier to enter static_cast<int> . I suppose you would write a lot of it otherwise, or you would not ask. This way, someone who reads your code knows exactly what you mean (i.e. type char as an integer) without having to look for a definition of a custom function.
Michael Kristofik
source share