wchar_t* unicoudToMuil(const char* cha)
{
wchar_t* tt = NULL;
int len = MultiByteToWideChar(CP_ACP,0,cha,-1,NULL,0);
wchar_t* gg = new wchar_t[len];
MultiByteToWideChar(CP_ACP,0,cha,-1,gg,len);
tt = gg; delete[] gg;
return tt;
}
在我的程序里
...wchar_t* tt = null;//这里我不想每次都new出来tttt = unicoudToMuil("测试");//tt这里是个乱值,请问应该如何解决
...
{
wchar_t* tt = NULL;
int len = MultiByteToWideChar(CP_ACP,0,cha,-1,NULL,0);
wchar_t* gg = new wchar_t[len];
MultiByteToWideChar(CP_ACP,0,cha,-1,gg,len);
tt = gg; delete[] gg;
return tt;
}
在我的程序里
...wchar_t* tt = null;//这里我不想每次都new出来tttt = unicoudToMuil("测试");//tt这里是个乱值,请问应该如何解决
...
解决方案 »
- 要实现一副位图在屏幕上移动的时候,能够显示他的移动轨迹。
- CWinApp::InitInstance调用SetRegistryKey函数,这个函数并没有指定注册表信息的路径啊!
- 判断 CListCtrl::GetItemState 的 LVIS_SELECTED 怎么老是不成功
- Activex控件怎么动态获取服务器的IP,大家帮帮忙,谢谢
- 请问如何判断某个exe文件是否为一个多线程应用程序?
- Faint了, 自画combobox, GetLBText得到乱码
- 求教,一个关于VC中由一个CEdit的继承类向CView类传递数据的问题
- vc和delphi间的通信
- 关于如何启动两个窗口,这两个窗口有先后次序!
- VC 服务程序里,可否进行 WinInet API 编程?谢谢~~~
- string m_str 为什么报错?
- Help!关于MFC的调试
const char* mm;tt = unicoudToMuil(mm); //这里是个变量,不是常量
wchar_t* unicoudToMuil(const char* cha)
{
static wchar_t* tt = NULL;
if(tt)
{
delete[] tt;
}
int len = MultiByteToWideChar(CP_ACP,0,cha,-1,NULL,0);
wchar_t* tt = new wchar_t[len];
MultiByteToWideChar(CP_ACP,0,cha,-1,tt,len);
return tt;
}
wchar_t* unicoudToMuil(const char* cha, wchar_t *output, int len);或者干脆就用string,wstring得了。
wchar_t* unicoudToMuil(const char* cha)
{
static wchar_t* tt = NULL;
if(tt)
{
delete[] tt;
}
int len = MultiByteToWideChar(CP_ACP,0,cha,-1,NULL,0);
tt = new wchar_t[len];
MultiByteToWideChar(CP_ACP,0,cha,-1,tt,len); return tt;
}
{
wchar_t* tt = NULL;
int len = MultiByteToWideChar(CP_ACP,0,cha,-1,NULL,0);
wchar_t* gg = new wchar_t[len];
MultiByteToWideChar(CP_ACP,0,cha,-1,gg,len);
tt = gg; delete[] gg;
return tt;
} 指针所指向的内存都已经delete了,返回的tt不出错才怪。