6.23.11 fwide Function
Sets and determines the width orientation of a stream.
Include
<wchar.h>
Prototype
int fwide(FILE * stream, int mode);
Arguments
stream
- the stream to write to
mode
- the stream orientation to set
Return Value
The function returns a positive value if, after the call, the stream has wide orientation, a negative value if the stream has byte orientation, or zero if the stream has no orientation.
Remarks
For positive values of mode
, the function attempts to make the stream wide
oriented; for negative values, it attempts to make the stream byte oriented. For a
mode
of zero, the orientation of the stream is not altered. Once a stream
has been oriented, subsequent calls to fwide()
do not change that stream's
orientation.
Example
#include <wchar.h>
#include <stdio.h>
void prStrOrient(int orientation)
{
if (orientation > 0)
puts("The stream is wide oriented");
else if (orientation < 0)
puts("The stream is byte oriented");
else
puts("The stream is not oriented");
}
int main(void)
{
FILE * myfile;
int ret;
if ((myfile = fopen("afile", "w")) == NULL)
wprintf(L"Cannot open afile\n");
else {
ret = fwide(myfile, 0);
prStrOrient(ret);
ret = fwide(myfile, 1); // set wide orientation
prStrOrient(ret);
ret = fwide(myfile, -1); // no further changes made
prStrOrient(ret);
fclose (myfile);
}
}
Example Output
Content of afile
.
The stream is not oriented
The stream is wide oriented
The stream is wide oriented