Name

fwide - sets and determines the orientation of a FILE stream

Library

libc.lib

Synopsis

  #include <stdio.h>
  #include <wchar.h>
  int fwide (FILE *stream, int mode);

Return values

The fwide function returns a value according to orientation after the call of fwide; a value less than zero if byte-oriented, a value greater than zero if wide-oriented, and zero if the stream has no orientation.

Detailed description

The fwide function determines the orientation of the stream pointed at by stream.

If the orientation of stream has already been determined, fwide leaves it unchanged. Otherwise, fwide sets the orientation of stream according to mode.

If mode is less than zero, stream is set to byte-oriented. If it is greater than zero, stream is set to wide-oriented. Otherwise, mode is zero, and stream is unchanged.


Examples

#include <stdio.h>
#include <wchar.h>
/* Illustrates how to use fwide API */
int example_fwide(void)
{
 FILE *fp = NULL;
 int retval;
 int mode;
 /* open a file */
 fp = fopen("input.txt","r");
 if(fp == NULL)
 {
  wprintf(L"Error: File open\n");
  return (-1);
 }
 /* set the mode to wide*/
 mode = 1;
 /* set the orientation of the file */
 retval = fwide(fp, mode);
 /*     check   the     return value */
 if(retval ==   1)
 {
        wprintf(L"Mode set to WIDE\n");
 }
 else
 {
        wprintf(L"Error setting the mode to wide!!\n");
 }
 /* set the mode to determine the orientation */
 mode = 0;
 /* Read back the orientation that was set */
 retval = fwide(fp ,mode);
 if(retval == 1)
 {
        wprintf("Mode not changed\n");
 }
 else
 {
        wprintf("Error, mode changed!!\n");
 }
 /* Close the file open for writing */
 fclose(fp);
 /* return the mode of fp */
 return (retval);
}



See also

ferror, fgetc in getc, fgetwc in getwc, fopen, fputc in putc, fputwc in putwc, freopen fopen

Feedback

For additional information or queries on this page send feedback

© 2008 Nokia Corporation. All rights reserved. This documentation can be used in the connection with this Product to help and support the user.

Top