Try to search your question here, if you can't find : Ask Any Question Now ?

writing unicode characters to file

HomeCategory: stackoverflowwriting unicode characters to file
Avatarsourav asked 3 months ago

I’m trying to write unicode characters to file with std::wofstream but the put function doesn’t write any characters.

Sample code:

#include <fstream>
#include <iostream>

int main()
    std::wofstream file;"output.txt", std::ios::app);
    if (file.is_open())
        wchar_t test = L'й';
        const wchar_t* str = L"фывдлао";
        file.write(str, sizeof(str));
        std::wcerr << L"Failed to open file" << std::endl;

    return 0;

output.txt file is empty, no wchar/string is written after executing code, why? what am I doing wrong?

1 Answers
Best Answer
AvatarJyoti answered 3 months ago
Your Answer

18 + 1 =

Popular Tags

WP Facebook Auto Publish Powered By :