ostream
Objects of class ostream
inherit the generic methods from
ios
, and in addition have the following methods available.
Declarations for this class come from iostream.h.
ostream
simply
allocates a new ios
object.
streambuf*
, to use an existing open stream for output. It also
accepts an optional second argument tie, to specify a related
ostream*
as the initial value for ios::tie
.
If you give the ostream
a streambuf
explicitly, using
this constructor, the sb is not destroyed (or deleted or
closed) when the ostream
is destroyed.
ostream
These methods write on an ostream
(you may also use the operator
<<
; see Operators).
ostream
,
beginning at the pointer string.
string may have any of these types: char*
, unsigned char*
, signed char*
.
fprintf(file, format, ...)
.
format is a printf
-style format control string, which is used
to format the (variable number of) arguments, printing the result on
this ostream
. See ostream::vform
for a version that uses
an argument list rather than a variable number of arguments.
vfprintf(file, format, args)
.
format is a printf
-style format control string, which is used
to format the argument list args, printing the result on
this ostream
. See ostream::form
for a version that uses a
variable number of arguments rather than an argument list.
ostream
You can control the output position (on output streams that actually support positions, typically files) with these methods:
ostream::tellp
). loc specifies an
absolute position in the output stream.
ios::seekdir
):
beg
cur
end
ostream
utilities
You may need to use these ostream
methods for housekeeping:
ostream
.
opfx
is a prefix method for operations on ostream
objects; it is designed to be called before any further processing. See
ostream::osfx
for the converse.
opfx
tests that the stream is in state good
, and if so
flushes any stream tied to this one.
The result is 1
when opfx
succeeds; else (if the stream state is
not good
), the result is 0
.
osfx
is a suffix method for operations on ostream
objects; it is designed to be called at the conclusion of any processing. All
the ostream
methods end by calling osfx
. See
ostream::opfx
for the converse.
If the unitbuf
flag is set for this stream, osfx
flushes
any buffered output for it.
If the stdio
flag is set for this stream, osfx
flushes any
output buffered for the C output streams stdout and stderr.