MFC中如何把CString与char数组互换

2025-02-24 20:39:38
推荐回答(3个)
回答1:

CString str=_T("你好");
char ch[4];
for(int i=0;i{
ch[i]=str.GetAt(i);
}

回答2:

给你看一小段例子:

char buff[128]="hello";
CString str;

str=buff; //因为CString 的 = 被重载,可以直接赋值
strcpy(buff,str.GetBuffer(128)); //GetBuffer可以拿到CString中字符串所存储的地址。

你再体会一下,应该就简单了。

回答3:

for(int i=0; i