Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Conversion of ATL CString to character array

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

My code is like this :

CString strCamIP1 = _T("");
char g_acCameraip[16][17];
strCamIP1 = theApp.GetProfileString(strSection, _T("IP1"), NULL);
g_acCameraip[0] = strCamIP1;
like image 363
Vaibhav Avatar asked May 14 '12 06:05

Vaibhav


1 Answers

This seems to be along the right lines; http://msdn.microsoft.com/en-us/library/awkwbzyc.aspx

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

which in your case would be along the lines of

strcpy(g_acCameraip[0], (LPCTSTR)strCamIP1);
like image 84
dutt Avatar answered Sep 21 '22 07:09

dutt