about wide character:
First try to understand how data is stored in a wchar_t variable. Its a two byte length. To accommodate old ascii data the sequence is like below:
According to your code it will stop writing when it gets a null character. and variable a
holds a null character in the first byte.
either of two things
1. Use a class which is capable of writing wide string
2. I dont know c++. but using stdin function where file must have to be open as binary. and you can do your writing without trouble
Also Debug the code below:
int _tmain(int argc, _TCHAR* argv)
if you debug you would see the stored character sequence is like below:
if you try to write the above string in a file using the class you have stated then you will get only "a" in the file. because in the second byte its getting string terminating character.
Note: for wide character string terminating character is sequence of two null value. but of course array[even_index] and array[even_index+1], not array[odd_index] and array[odd_index+1]. as example array and array but not array and array. here array is single byte string