ungetwc Function

Pushes a wide character back to an input stream.

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

Include

<wchar.h>

Prototype

wint_t ungetwc(wint_t c, FILE *stream);

Arguments

c
the wide character to push back
stream
the stream to accept the wide character

Return Value

The function returns the wide character pushed back, or WEOF if the operation fails.

Remarks

The getwc() function is equivalent to fgetwc(). 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;
  wchar_t buffer[256];

  myfile = fopen("afile", "rt");
  if(myfile!=NULL)
    while(!feof (myfile)) {
      wc=getwc(myfile);
      if (wc != WEOF) {
        if (iswlower(wc)) // is the first wide char lower case
          ungetwc(towupper(wc), myfile);  // make it upper case
      else
          ungetwc(wc, myfile);
      fgetws(buffer, 255, myfile);
      fputws(buffer, stdout);
    }
  }
}

Example Input

Content of afile.

The curious CASE of this File
the button on the Shirt
The function of this task

Example Output

The curious CASE of this File
The button on the Shirt
The function of this task