fputwc, putwc
來自 cppreference.com
在標頭檔案 <wchar.h> 中定義 |
||
wint_t fputwc( wchar_t ch, FILE* stream ); |
(1) | (自 C95 起) |
wint_t putwc( wchar_t ch, FILE* stream ); |
(2) | (自 C95 起) |
將寬字元 ch 寫入給定的輸出流 stream。
2) 可能被實現為宏,並可能多次評估 stream。
目錄 |
[編輯] 引數
ch | - | 要寫入的寬字元 |
stream | - | 輸出流 |
[編輯] 返回值
成功時,返回 ch 的副本。
失敗時,返回 WEOF 並在 stream 上設定 *錯誤* 指示器(參閱 ferror())。
如果發生編碼錯誤,還會將 errno 設定為 EILSEQ。
[編輯] 示例
執行此程式碼
#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."); else puts("I/O error in fputwc."); return EXIT_FAILURE; } }
可能的輸出
🍌
[編輯] 參考資料
- C23 標準 (ISO/IEC 9899:2024)
- 7.31.3.3 fputwc 函式 (p: 430)
- 7.31.3.8 putwc 函式 (p: 431-432)
- C17 標準 (ISO/IEC 9899:2018)
- 7.29.3.3 fputwc 函式 (p: 308)
- 7.29.3.8 putwc 函式 (p: 310)
- C11 標準 (ISO/IEC 9899:2011)
- 7.29.3.3 fputwc 函式 (p: 422-423)
- 7.29.3.8 putwc 函式 (p: 424)
- C99 標準 (ISO/IEC 9899:1999)
- 7.24.3.3 fputwc 函式 (p: 368)
- 7.24.3.8 putwc 函式 (p: 370)
[編輯] 另請參閱
向檔案流寫入一個字元 (函式) | |
(C95) |
向檔案流寫入一個寬字串 (函式) |
(C95) |
從檔案流中獲取一個寬字元 (函式) |
C++ 文件 用於 fputwc
|