Chapter 11. C I/O Library Functions

The old-style C I/O functions (printf, fprintf, and so on) comprise another area of the library supported for backward compatibility. If you have a choice, you should use the C++ I/O stream classes and objects such as cin and cout to perform input and output. The advantages of the latter are that they have greater flexibility and ease of use; in particular, you can extend your own classes to work with them. They also work more smoothly with the C++ Standard Template Library (STL) string class.

printf, scanf, fprintf, and other old-style C I/O functions support a fixed set of format specifiers that cannot be extended to work with classes and do not work directly with the string class.

For these reasons, I definitely ...

Get C++ for the Impatient now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.