std::fputwc
来自 cppreference.cn
定义于头文件 <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。
目录 |
[edit] 参数
ch | - | 要写入的宽字符 |
stream | - | 输出流 |
[edit] 返回值
成功时返回 ch,失败时返回 WEOF。如果发生编码错误,errno 会被设置为 EILSEQ。
[edit] 示例
运行此代码
#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 name: "FOR ALL" L'\n', L'∀', }) { if (errno = 0; std::fputwc(ch, stdout) == WEOF) { std::puts(errno == EILSEQ ? "Encoding error in fputwc" : "I/O error in fputwc" ); return EXIT_FAILURE; } } return EXIT_SUCCESS; }
可能的输出
∀ ∀
[edit] 参见
向文件流写入字符 (函数) | |
向文件流写入宽字符串 (函数) | |
从文件流获取宽字符 (函数) | |
C 文档 关于 fputwc
|