之前写过CString的用法;
VC++ CString 编程实例图解_bcbobo21cn, cstring-CSDN博客
下面单独看一下CString的各种初始化方式;
void CTest2View::OnDraw(CDC* pDC)
{CTest2Doc* pDoc = GetDocument();ASSERT_VALID(pDoc);// TODO: add draw code for native data hereCString str1="AAA";CString str2("BBB");char szbuf[] = "CCC";CString str3(szbuf);CString str4=szbuf;char * p = "DDD";CString str5(p);CString str6=p;CString str7(str1);CString str8=str7;pDC->TextOut(20,20,str1);pDC->TextOut(20,50,str2);pDC->TextOut(20,80,str3);pDC->TextOut(20,110,str4);pDC->TextOut(20,140,str5);pDC->TextOut(20,170,str6);pDC->TextOut(20,200,str7);pDC->TextOut(20,230,str8);
}
可以赋值,赋值有不同的写法;
可以由char [] 和 char * 转化为CString;
可以用其他CString对象来初始化;