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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.