[C++] wstringでエンコードされたデータをファイルに書き込む

wstring の場合

#include <iostream>
#include <fstream>

int main()
{
    std::wstring text(L"hello, world");
    std::basic_ofstream<wchar_t> ofs("C:\\hoge1.txt", std::ios::binary);
    ofs.write(text.data(), text.size());
}

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です