Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      fputwc, putwc

      From cppreference.com
      <c‎ |io
       
       
      File input/output
      Types and objects
      Functions
      File access
      Unformatted input/output
      (C95)(C95)
      (C95)
      fputwcputwc
      (C95)(C95)
      (C95)
      (C95)

      Formatted input
       
      Defined in header<wchar.h>
      wint_t fputwc(wchar_t ch,FILE* stream);
      (1)(since C95)
      wint_t putwc(wchar_t ch,FILE* stream);
      (2)(since C95)

      Writes a wide characterch to the given output streamstream.

      2) May be implemented as a macro and may evaluatestream more than once.

      Contents

      [edit]Parameters

      ch - wide character to be written
      stream - the output stream

      [edit]Return value

      Returns a copy ofch on success.

      On failure, returnsWEOF and sets theerror indicator (seeferror()) onstream.

      If an encoding error occurred, additionally setserrno toEILSEQ.

      [edit]Example

      Run this code
      #include <errno.h>#include <locale.h>#include <stdio.h>#include <stdlib.h>#include <wchar.h> int main(void){setlocale(LC_ALL,"en_US.utf8"); errno=0;if(fputwc(L'🍌',stdout)== WEOF){if(errno==EILSEQ)puts("Encoding error in fputwc.");elseputs("I/O error in fputwc.");returnEXIT_FAILURE;}}

      Possible output:

      🍌

      [edit]References

      • C23 standard (ISO/IEC 9899:2024):
      • 7.31.3.3 The fputwc function (p: 430)
      • 7.31.3.8 The putwc function (p: 431-432)
      • C17 standard (ISO/IEC 9899:2018):
      • 7.29.3.3 The fputwc function (p: 308)
      • 7.29.3.8 The putwc function (p: 310)
      • C11 standard (ISO/IEC 9899:2011):
      • 7.29.3.3 The fputwc function (p: 422-423)
      • 7.29.3.8 The putwc function (p: 424)
      • C99 standard (ISO/IEC 9899:1999):
      • 7.24.3.3 The fputwc function (p: 368)
      • 7.24.3.8 The putwc function (p: 370)

      [edit]See also

      writes a character to a file stream
      (function)[edit]
      (C95)
      writes a wide string to a file stream
      (function)[edit]
      gets a wide character from a file stream
      (function)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=c/io/fputwc&oldid=158956"

      [8]ページ先頭

      ©2009-2025 Movatter.jp