본문 바로가기

업무 채널

[MFC] Cstring <-> Char* 형변환


CString Char* 형 변환 하는법
 

CString -> Char *

 

CString strBuffer;
char szBuffer[MAX_PATH] = {0,};
int nLength = (MAX_PATH > strlen(strBuffer)) ? strlen(strBuffer) : MAX_PATH;
strncpy(szBuffer, (LPSTR)(LPCSTR)strBuffer, nLength);


 

Char * -> CString

CString strBuffer;
char szBuffer[MAX_PATH];
strBuffer = (LPSTR)szBuffer;