Name
fwide function — Gets or sets stream orientation
Synopsis
int fwide(FILE* stream, int mode);
The fwide
function gets or
sets the orientation of stream
.
The orientation is wide or narrow (byte). When a file is opened, it
starts without orientation. Calling any wide I/O function on the
stream gives it wide orientation. Calling any narrow I/O function on
the stream gives it narrow orientation. Mixing narrow and wide
functions on a stream results in an error—that is, calling a narrow
function on a stream with wide orientation or calling a wide
function on a stream with narrow orientation results in an
error.
Before performing any I/O on a newly opened stream, you can
force the stream’s orientation by calling fwide
. Once the orientation is set, it
cannot be changed except by closing and reopening the stream (for
example, by calling freopen
in
<cstdio>
).
If mode
is positive, the
orientation is set to wide. If mode
is negative, the orientation is set
to narrow. If the orientation has already been set, it is not
changed, and the stream’s true orientation is returned. If mode
is 0
, the orientation is queried without
being changed.
The return value indicates the new orientation: positive for
wide, negative for narrow, or 0
if the stream has no orientation.
Get C++ In a Nutshell 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.