putwc - C wchar.h

C examples for wchar.h:putwc

Type

function

From


<cwchar>
<wchar.h>

Prototype

wint_t putwc (wchar_t wc, FILE* stream);

Description

Write wide character to stream

Parameters

Parameter Description
wc The wide character to write.
stream Pointer to a FILE object

Return Value

On success, the character written is returned.

On error, it returns WEOF.

Demo Code


#include <stdio.h>

int main ()//  w  w  w . j  a v a2  s .  c  o m
{
  FILE * pFile;
  wchar_t wc;

  pFile = fopen ("example.txt","w");
  if (pFile!=NULL) {
     perror("cannot open file");
     
     return -1;
  }
  for (wc = L'A' ; wc <= L'Z' ; ++wc)
      putwc ( wc , pFile );

  fclose (pFile);

  return 0;
}

Related Tutorials