Comparison of iostreams and stdio
The stdio library served C programmers well for many years.
However, it has several deficiencies:
-
The use of functions, like
printf(),
that accept variable numbers
and types of arguments mean that type checking is subverted at an
important point in many programs.
-
There is no mechanism for extending it to user defined classes.
The only way to add new format specifiers to
printf()
is to reimplement it.
-
The mechanism is closely tied to file
I/O.
sprintf()
explicitly extends it to incore operations, but there is no general
method for creating alternate sources and sinks of data.
The iostream library for C++ has been designed to solve all of these
problems.
Next topic:
Converting from streams to iostreams
Previous topic:
Extending state variables
© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 27 April 2004