std::fputwc
来自cppreference.com
在标头 <cwchar> 定义 | ||
std::wint_t fputwc(wchar_t ch, std::FILE* stream ); | (1) | |
std::wint_t putwc(wchar_t ch, std::FILE* stream ); | (2) | |
写入宽字符 ch 到给定的输出流 stream。
2) 可实现为宏并可能求值 stream 多于一次。
目录 |
[编辑]参数
ch | - | 要写入的宽字符 |
stream | - | 输出流 |
[编辑]返回值
成功时为 ch,失败时为 WEOF。若出现编码错误,则设置 errno 为 EILSEQ。
[编辑]示例
运行此代码
#include <cerrno>#include <clocale>#include <cstdio>#include <cstdlib>#include <cwchar>#include <initializer_list> int main(){std::setlocale(LC_ALL, "en_US.utf8"); for(constwchar_t ch :{ L'\u2200', // Unicode 名: "FOR ALL" L'\n', L'∀', }){if(errno=0; std::fputwc(ch, stdout)== WEOF){std::puts(errno==EILSEQ?"fputwc 中的编码错误":"fputwc 中的 I/O 错误");returnEXIT_FAILURE;}}returnEXIT_SUCCESS;}
可能的输出:
∀ ∀
[编辑]参阅
写字符到文件流 (函数) | |
写宽字符串到文件流 (函数) | |
从文件流获取宽字符 (函数) | |
fputwc 的 C 文档 |