fwide - C wchar.h

C examples for wchar.h:fwide

Type

function

From


<cwchar>
<wchar.h>

Description

Stream orientation

Prototype

int fwide (FILE* stream, int mode);

Description

Determines the orientation of stream.

If orientation is not set, it may be set, depending on the value of mode.

Parameters

Parameter Description
stream Pointer to a FILE object.
mode May specify an orientation:

The mode could have the following value.

Mode Description
0 does not change the orientation of the stream.
>0 makes the stream wide-oriented.
<0 makes the stream byte-oriented.

Return Value

depending on the stream orientation after the call:

Return Value Description
0 indicates that the stream has no orientation yet.
>0 indicates that the stream is wide-oriented.
<0 indicates that the stream is byte-oriented.

Demo Code


#include <stdio.h>
#include <wchar.h>

int main ()//from ww  w .  j a va 2 s  .  c o  m
{
  FILE * pFile;
  int ret;

  pFile = fopen ("main.cpp","a");

  if (pFile == NULL){
     perror("cannot open file");
     return -1;
  }  

  fwide (pFile,1);
  ret = fwide (pFile,0);
  if (ret>0) 
       puts ("The stream is wide-oriented");
  else if (ret<0) 
       puts ("The stream is byte-oriented");
  else 
       puts ("The stream is not oriented");
  fclose (pFile);

  return 0;
}

Related Tutorials