fputwc Function

Writes a wide character to a stream.

Attention: This function is implemented only by MPLAB XC32 C compilers.

Include

<wchar.h>

Prototype

wint_t fputwc(wchar_t c, FILE * stream);

Arguments

 c the wide character to write  stream the stream to write to

Return Value

The function returns a copy of the wide character written. If a write or encoding error occurs, WEOF is returned.

Remarks

The function writes the wide character, c, to the output stream pointed to by stream and at the position indicated by the file position indicator for the stream (if defined), advancing the indicator appropriately. If positioning within the file is not supported or if the stream was opened with append mode, the character is appended to the output stream.

The error indicator for the stream will be set on a write error. If an encoding error occurs, errno is set to the value of the EILSEQ macro.

Example

#include <wchar.h>

int main(void)
{
FILE * myfile;
wint_t wc;

if ((myfile = fopen("afile", "w")) == NULL)
wprintf(L"Cannot open afile\n");
else
{
for(wc = L'0'; iswdigit(wc); wc++)
fputwc(wc, myfile);
fputwc(L'\n', myfile);
fclose(myfile);
}
}

Example Output

Content of afile.

0123456789