# Include <iostream>
# Include <fstream>
# Include <windows. h>
Using namespace STD;
Int main ()
{
File * FP;
Wchar [5] = l "equal to equal"; // defines a wide-Byte variable, initially equal to "equal"
Fp = fopen ("1.txt"," W + "); // open the file called Odo
Fwprintf (FP, l "% s \ n", wchar); // output to file
Fclose (FP); // close the file
Wchar wc2 [5]; // defines the second wide BYTE Variable
// There are many width-byte operations starting with WC. Corresponds to Str.
Wcscpy (wc2, wchar); // copy.
Int n = wcscmp (wc2, wchar); // comparison
If (n = 0)
{
Wprintf (L "equal \ n"); // do you notice that there is no problem with wprintf.
}
Char STR [10]; // defines the char character.
N = wcstombs (STR, wc2, 9); // converts a wide byte to muiltychar
Printf ("% s \ n", STR); // output result
For (INT I = 0; I <5; ++ I)
{
Wc2 [I] = L '1' + I;
}
Wc2 [4] = 0;
N = wcstombs (STR, wc2, 9); // converts a wide byte to muiltychar
Printf ("% s \ n", STR); // output result
// Another Conversion Method
N = widechartomultibyte (cp_acp, null, wchar, wcslen (wchar) + 1, STR, 10, 0, 0 );
Printf ("% s \ n", STR );
Char str2 [10] = "1 ";
Wchar wc3 [10];
N = multibytetowidechar (cp_acp, null, str2, strlen (str2) + 1, wc3, 10); // Char to the width byte.
System ("pause ");
Return 0;
}