Previous Page
Next Page

fputws

Writes a string of wide characters to a file

#include <wchar.h>
int fputws ( const wchar_t * restrict ws , FILE * restrict fp  );

The fputws( ) function writes a string of wide characters to the file specified by the FILE pointer argument. The string is written without the terminator character (L'\0'). If successful, fputws( ) returns a value greater than or equal to zero. A return value of EOF indicates that an error occurred.

Example

FILE *fpw;
char fname_wide[ ] = "widetest.txt";
int widemodeflag = 1;
int result;

wchar_t widestring[ ] = L"How many umlauts are there in Fahrvergnügen?\n";

if ((fpw = fopen(fname_wide, "a")) == NULL)
  perror( "Opening output file" ), return -1;

// Set file to wide-character orientation:
widemodeflag = fwide(fpw, widemodeflag);
if ( widemodeflag <= 0 )
{
  fprintf(stderr, "Unable to set output file %s to wide characters\n",
          fname_wide);
  (void)fclose(fpw);
  return -1;
}

// Write wide-character string to the file:
result = fputws( widestring, fpw );

See Also

fgets( ), fputs( ), fgetws( ), fwprintf( )


Previous Page
Next Page