I need to print unicode symbols to the file, but I get their codes instead.
Here is an example:
#include <iostream> #include <fstream> using namespace std; int main () { int code = 33; wchar_t sym = wchar_t(code); ofstream output ("output.txt"); output << sym << "\n"; output.close(); return 0; } So I expect to see ! in my file, but I see 33. How can I fix it?
std::wofstreaminstead. And FYI, cplusplus.com is generally considered to be a poor C++ reference site, you should use cppreference.com (wofstream)