It will be easier for you to understand both "C-style" I/O and "iostream-style" I/O if you remember that there are at least two fundamentally different things going on when you "output" some data (and likewise, in reverse, when you input some data). Just to have some sort of name for them, let's refer to them as formatting and buffering:
- Formatting is the task of taking a bunch of strongly typed data values from the
program--ints, strings, floating-point numbers, user-defined class types--and translating or serializing them into "text." For example, when the number 42 is printed out as "42" (or "+42" or "0x002A"), that's formatting. Generally, a formatting library will have its own "mini-language" to describe how you want each value to be formatted. - Buffering...