std::fputws

出自cppreference.com
< cpp | io | c
 
 
 
 
在標頭 <cwchar> 定義
int fputws( const wchar_t* str, std::FILE* stream );

將空終止寬字符串 str 的每個寬字符寫入到輸出流 stream,如同通過重複執行 std::fputwc 進行。

不寫入 str 的終止寬字符。

參數

str - 要寫入的空終止寬字符串
stream - 輸出流

返回值

成功時返回非負值。

失敗時,返回 EOF 並設置 stream 上的錯誤指示器(見 std::ferror)。

示例

#include <clocale>
#include <cstdio>
#include <cwchar>
 
int main()
{
    std::setlocale(LC_ALL, "en_US.utf8");
    int rc = std::fputws(L"御休みなさい", stdout);

    if (rc == EOF)
        std::perror("fputws()"); // POSIX 要求设置 errno
}

可能的輸出:

御休みなさい

參閱

寫字符串到文件流
(函數) [編輯]
列印有格式寬字符輸出到 stdout、文件流或緩衝區
(函數) [編輯]
寫寬字符串到文件流
(函數) [編輯]
從文件流獲取寬字符串
(函數) [編輯]
fputws 的 C 文檔