ATL CString 到字符数组的转换

2022-01-12 00:00:00 char visual-c++ c++ c-strings

我想转换 CString 转换成 char[].有人告诉我该怎么做?

I want to convert a CString into a char[]. Some body tell me how to do this?

我的代码是这样的:

CString strCamIP1 = _T("");
char g_acCameraip[16][17];
strCamIP1 = theApp.GetProfileString(strSection, _T("IP1"), NULL);
g_acCameraip[0] = strCamIP1;

推荐答案

这似乎是正确的;http://msdn.microsoft.com/en-us/library/awkwbzyc.aspx

CString aCString = "A string";
char myString[256];
strcpy(myString, (LPCTSTR)aString);

在你的情况下是这样的

strcpy(g_acCameraip[0], (LPCTSTR)strCamIP1);

相关文章