wsprintf(buffer, "%S", c); // a CAPITAL S
MessageBox (0, buffer , buffer , 0) ;
Error message :
C:\programs\Vc_Studio6\AIS01\ch01\widecharacter04\widecharacter04.cpp(23) : error C2440: 'initializing' : cannot convert from 'char [9]' to 'unsigned short [9]'
There is no context in which this conversion is possible
Error executing cl.exe.
// UNICODE not defined before windows.h
#include <windows.h>
char buffer[1024] = "";
staticwchar_t c[9]=L"Hello!WC"; // with added L
wsprintf(buffer, "%S", c); // a CAPITAL S
MessageBox (0, buffer , buffer , 0) ;
With UNICODE defined most of the Windows API calls which take strings switch to use UNICODE
1 2 3 4 5 6 7 8 9 10
// with UNICODE not defined before windows.h
#define UNICODE
#include <windows.h>
wchar_t buffer[1024] = L""; // with added L
staticwchar_t c[9]=L"Hello!WC"; // with added L
wsprintf(buffer, L"%s", c); // now a small s, and an added L
MessageBox (0, buffer , buffer , 0) ;