how to write wchar_t in file

Hi everyone, i have array of wchar_t elements, which i want to write to file, but when I try to write, in file it only appear decimal value for each letter, so can anyone tell me what is problem.

Here is code how I trying to write to file:

1
2
3
4
5
6
7
8
string file_name = name;
fstream output (file_name.c_str(), ios::binary|ios::out);
 
for(i=0; i<sizeof(n); i++)
{
    for(j=0; j<brojslova; j++)
        output<<i+1<<".\t"<< static_cast<wchar_t> (stats[i].letter[j]) << '\t' <<stats[i].count/sum_letter<<endl;
}


I have actually a struct of two element (one is type wchar_t letter[5], and other is double count), and i want to write in every line of file, a one element of that struct

PS: I use windows platfom, and Visual Studio 2010
Last edited on
The easiest way with a Microsoft compiler on Windows is to use a std::wofstream instead of std::ofstream.
with std::wofstream everthing is ok, until there is a letter that doesn't belong to ansi
What goes wrong when you have a letter that doesn't belong to ansi?
Last edited on
when letter isn't ASCII it stop writing to file
Topic archived. No new replies allowed.