- CString to char*
1. memcpy
CString str = "test";
unsigned char st[30];
memcpy(st, (unsigned char*)(LPCTSTR)str,str.GetLength());
2. strcpy
CString strData = "test";
int length = strData.GetLength();
char* st = new char[length];
strcpy(st, strData.GetBuffer(0));
3. Type convert
CString str;
str = "test";
char* st = LPSTR(LPCTSTR(str));
- char* to CString
Using Format function in CString class
char st[] = "test";
CString str;
str.Format("%s", st);
Using Format function in CString class
char st[] = "test";
CString str;
str.Format("%s", st);
No comments:
Post a Comment