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 求值不止一次。
| 目录 | 
[编辑] 参数
| 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 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; }
可能的输出
∀ ∀
[编辑] 参阅
| 向文件流写入一个字符 (函数) | |
| 向文件流写入一个宽字符串 (函数) | |
| 从文件流中获取一个宽字符 (函数) | |
| C 文档 关于 fputwc | |


