December 2005
Beginner to intermediate
618 pages
20h 19m
English
fputws
Writes a string of wide characters to a file
#include <wchar.h> intfputws( const wchar_t * restrictws, FILE * restrictfp);
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.
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 );Read now
Unlock full access