约 928 字

约 5 分钟

#C 语言标准库函数 fputws

#include <wchar.h>

int fputws(const wchar_t *restrict s, FILE *restrict stream);

说明

向流写出宽字符串,省略结尾的空宽字符,保持原有换行。

宽字符 I/O 使用流定向。一个流确定定向后,应按相同定向操作。

自 C95 起提供。

参数

  • s - 以空宽字符结束的输入数组。
  • stream - 可进行宽字符 I/O 的有效流。

返回值

  • 成功返回非负值,失败返回 EOF。

#示例

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

int main(void)
{
    FILE *stream = tmpfile();
    if (stream == NULL) {
        return 1;
    }
    int ok = fputws(L"A\n", stream) >= 0;
    int closed = fclose(stream);
    return !ok || closed != 0;
}

#相关接口

#参考标准

更新: 2026/11/28

作者: planc

创建: 2026/11/28