约 908 字

约 5 分钟

#C 语言标准库函数 putwc

#include <wchar.h>

wint_t putwc(wchar_t c, FILE *stream);

说明

向指定流写入一个宽字符。

宽字符 I/O 使用流定向。一个流确定定向后,应按相同定向操作。宏实现可能多次求值流参数,应使用没有副作用的表达式。

自 C95 起提供。

参数

  • c - 要写出的宽字符。
  • stream - 可进行宽字符 I/O 的有效流。

返回值

  • 成功返回写入的宽字符,失败返回 WEOF。

#示例

#include <wchar.h>
#include <stdio.h>

int main(void)
{
    FILE *stream = tmpfile();
    if (stream == NULL) {
        return 1;
    }
    int ok = putwc(L'A', stream) == L'A';
    int closed = fclose(stream);
    return !ok || closed != 0;
}

#相关接口

#参考标准

更新: 2026/11/28

作者: planc

创建: 2026/11/28