Streams are generally quite safe. Under some circumstances, they can be slow and/or clumsy. Slow, mostly stems from the fact that they impose a few extra layers between your code and the OS, and under the wrong circumstance those layers can add overhead. The clumsiness is mostly in comparison to C's printf, not direct use of something like WriteFile (which doesn't directly support formatting at all). For example, however, consider:
printf("%2.2x", ch);`
to
std::cout << std::hex << std::setw(2) << std::setprecision(2) << std::setfill('0') << ch;
std::cout << setfill(' ');
Then consider the fact that if you care about i18n, printf
is using a string that's easy to read in from an external source, where the C++ stream is embedding all the formatting into the structure of the code, so nearly any change in formatting requires rewriting the code, recompiling and relinking.
CreateFile, ReadFile
, etc, also allow a number of things like memory mapped files and overlapped reading and writing that aren't supported by iostreams at all. If the situation lets you make good use of these, iostreams often won't be competitive.