std:: fputwc
From cppreference.net
C++
Input/output library
| I/O manipulators | ||||
| Print functions (C++23) | ||||
| C-style I/O | ||||
| Buffers | ||||
|
(C++23)
|
||||
|
(
C++98/26*
)
|
||||
|
(C++20)
|
||||
| Streams | ||||
| Abstractions | ||||
| File I/O | ||||
| String I/O | ||||
| Array I/O | ||||
|
(C++23)
|
||||
|
(C++23)
|
||||
|
(C++23)
|
||||
|
(
C++98/26*
)
|
||||
|
(
C++98/26*
)
|
||||
|
(
C++98/26*
)
|
||||
| Synchronized Output | ||||
|
(C++20)
|
||||
| Types | ||||
| Error category interface | ||||
|
(C++11)
|
||||
|
(C++11)
|
C-style I/O
| Types and objects | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Functions | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
定义于头文件
<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 名称:"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; }
可能的输出:
∀ ∀
参见
|
向文件流写入一个字符
(函数) |
|
|
向文件流写入一个宽字符串
(函数) |
|
|
从文件流获取一个宽字符
(函数) |
|
|
C documentation
for
fputwc
|
|