The input stream is therefore tied to the output stream such that a request for input will cause pending output to be flushed. Disabling the linkage between the input and output streams gets rid of this overhead. If the input stream is untied, then the prompt in the example above will not come out before input is requested from the user, leading to confusion. Note also that current libraries vary in their behavior. The above example works for one library that was tried, but for another, there appears to be no way to disable unit buffering under any circumstances, when output is to a terminal.
Copying files a character at a time has other pitfalls.
One has to be careful in assessing the buffering and function call overhead for anything done on a per-character basis. There is yet another way of copying files by character, using streambufs, that we'll present in a future issue. Perhaps the most critical factor is whether functions that are used in a given case are inlined or not. Note also that if you are copying binary files you need to be careful with the way copying is done. All of these methods use streambufs in some form.