2018-12-06

#include 
int fwide(FILE *fp, int mode);
Returns: positive if stream is wide oriented,
negative if stream is byte oriented,
or 0 if stream has no orientation

The fwide function performs different tasks, depending on the value of the mode
argument.
• If the mode argument is negative, fwide will try to make the specified stream
byte oriented.
• If the mode argument is positive, fwide will try to make the specified stream
wide oriented.
• If the mode argument is zero, fwide will not try to set the orientation, but will
still return a value identifying the stream’s orientation.
Note that fwide will not change the orientation of a stream that is already oriented.
Also note that there is no error return. Consider what would happen if the stream is
invalid. The only recourse we have is to clear errno before calling fwide and check
the value of errno when we return. Throughout the rest of this book, we will deal only
with byte-oriented streams.
When we open a stream, the standard I/O function fopen (Section 5.5) returns a
pointer to a FILE object. This object is normally a structure that contains all the
information required by the standard I/O library to manage the stream: the file
descriptor used for actual I/O, a pointer to a buffer for the stream, the size of the buffer,
a count of the number of characters currently in the buffer, an error flag, and the like.
Application software should never need to examine a FILE object. To reference the
stream, we pass its FILE pointer as an argument to each standard I/O function.
Throughout this text, we’ll refer to a pointer to a FILE object, the type FILE *, as a file
pointer.
Throughout this chapter, we describe the standard I/O library in the context of a
UNIX system. As we mentioned, this library has been ported to a wide variety of other
operating systems. To provide some insight about how this library can be
implemented, we will talk about its typical implementation on a UNIX system.

你可能感兴趣的:(2018-12-06)