The simple answer is no. The mode is determined when the iostream object is constructed and cannot be changed later. Some implementations may provide facilities for this later, but this is not standardized. In some implementations, executing freopen on stdout may change the mode, although I believe that this is formal, it is forbidden in C ++. (This implementation is defined in C.) And, apparently, it does not work on your implementation.
It is best to find out what your system calls the console device ( "/dev/tty" under Unix; "CONS" , I think, on Windows), open it in the desired mode and output it to it.
James kanze
source share