Namespaces
Variants

fputws

From cppreference.net
< c ‎ | io
定义于头文件 <wchar.h>
int fputws ( const wchar_t * str, FILE * stream ) ;
(自 C95 起)
(直至 C99)
int fputws ( const wchar_t * restrict str, FILE * restrict stream ) ;
(自 C99 起)

将空终止宽字符串 str 中的每个字符写入输出流 stream ,如同重复执行 fputwc 函数。

来自 str 的终止空宽字符不会被写入。

目录

参数

str - 要写入的以空字符结尾的宽字符串
stream - 输出流

返回值

成功时,返回非负值

失败时返回 EOF 并在 stream 上设置错误指示器(参见 ferror )。

示例

#include <locale.h>
#include <stdio.h>
#include <wchar.h>
int main(void)
{
    setlocale(LC_ALL, "en_US.utf8");
    int rc = fputws(L"御休みなさい", stdout);
    if (rc == EOF)
       perror("fputws()"); // POSIX要求必须设置errno
}

输出:

御休みなさい

参考文献

  • C11 标准 (ISO/IEC 9899:2011):
  • 7.29.3.4 fputws 函数 (页: 423)
  • C99 标准 (ISO/IEC 9899:1999):
  • 7.24.3.4 fputws 函数 (页: 368)

参见

将字符串写入文件流
(函数)
将格式化宽字符输出打印到 stdout 、文件流或缓冲区
(函数)
fputws
(C95)
将宽字符串写入文件流
(函数)
(C95)
从文件流获取宽字符串
(函数)
C++ 文档 关于 fputws