c++中怎么把Cstring转成char*类型? 小弟试着百度了好多种方案,但是没有一种成功的啊。
2016-12-28
展开全部
Cstring 要项目的语言编码有关的
CString st=_T("123");
int nLength = st.GetLength();
int nBytes = WideCharToMultiByte(CP_ACP,0,st,nLength,NULL,0,NULL,NULL);
char* path1 = new char[ nBytes + 1];
memset(path1,0,nLength + 1);
WideCharToMultiByte(CP_OEMCP, 0, st, nLength, path1, nBytes, NULL, NULL);
path1[nBytes] = 0;
CString st=_T("123");
int nLength = st.GetLength();
int nBytes = WideCharToMultiByte(CP_ACP,0,st,nLength,NULL,0,NULL,NULL);
char* path1 = new char[ nBytes + 1];
memset(path1,0,nLength + 1);
WideCharToMultiByte(CP_OEMCP, 0, st, nLength, path1, nBytes, NULL, NULL);
path1[nBytes] = 0;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询