std::fputwc
来自cppreference.com
| 在标头 <cwchar> 定义
|
||
| |
(1) | |
| |
(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 (const wchar_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 错误"
);
return EXIT_FAILURE;
}
}
return EXIT_SUCCESS;
}
可能的输出:
∀
∀
参阅
| 写字符到文件流 (函数) | |
| 写宽字符串到文件流 (函数) | |
| 从文件流获取宽字符 (函数) | |
fputwc 的 C 文档
| |