TCHAR tcScriptName[MAX_PATH];
tcScriptName = "filename";
size_t i;
char tmp[MAX_PATH];
mbstate_t mbstate;
// Reset to initial shift state
::memset((void*)&mbstate, 0, sizeof(mbstate));
const wchar_t* wt = tcScriptName;
wcsrtombs_s(&i, tmp, MAX_PATH, &wt, MAX_PATH,&mbstate);
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
char * input = null;
wchar_t wc_input[MAX_USERNAME_LEN] = L"test";
int nLen = WideCharToMultiByte( CP_ACP, 0, wc_input, -1, NULL, 0, NULL, NULL );
int i = wcslen(wc_input)*sizeof(wchar_t);
input = (char*)realloc(input,i+1);
if (!input)
{
free(input);
input = (char*)malloc(i + 1);
}
WideCharToMultiByte( CP_ACP, 0, wc_input, -1, input, nLen, NULL, NULL );