 |
Lu Tao的意见:
CString Msg;
Msg=Msg+"abc";
LPTSTR lpsz;
lpsz = new TCHAR[Msg.GetLength()+1];
_tcscpy(lpsz, Msg);
char * psz;
strcpy(psz,lpsz);
doublehu的意见:
char *ch;
CString str;
ch=(LPSTR)(LPCTSTR)str;
陈啸龙的意见:
CString mCS=_T("cxl");
char mch[20];
memcpy(mch,mCS,20);
李海、阿进的意见:
使用CString::GetBuffer函数。例子:
char *p;
CString str("hello");
p=str.GetBuffer(str.GetLength());
榕溶的意见:
CString aaa="aaa";
char *ch
ch=aaa.c_str;
相关问题:
QA002733 "WriteFile函数中的字符数组能否用CString对象来替代"
longbow问: 反过来怎么办?即如何将char*类型的变量赋给cstring型的变量?
李海:这很容易,可以直接赋值,如:
CString myString = "This is a test";
也可以利用构造函数,如:
CString s1( "Tom" );
此问题由Lu Tao等回答。
附加关键字:编程, 源程序, programming, source code, C/C++, MFC, C++ Builder, Borland C++, Turbo C, C, BCB, 其他方面, 。
|