putwc 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 putwc(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 putwc() function is equivalent to fputwc(). It is implemented as a XXXX in MPLAB XC16 and XC32 (hence it may evaluate stream more than once).

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++)
      putwc(wc, myfile);
    fclose(myfile);
  }
}

Example Output

Content of afile.

0123456789