#include <xstring>
#include <iostream>
#include <comdef.h>
using namespace std;
char* ws2s(const wstring& ws)
{
_bstr_t t = ws.c_str();
char* pchar = (char*)t;
string result = pchar;
char* charTmp = new char;
strcpy(charTmp,result.c_str());
pchar = NULL;
delete pchar;
return charTmp;
}
void main()
{
wstring w = L"hello world\n";
char* s = ws2s(w);
cout<<s;
system("pause");
}