常用数据类型转换CString double char int WCHAR

WCHAR -> CString

WCHAR ch1[10]=”abc”; CString ch2; Ch2=ch1;

CString->WCHAR

CString src =”abc” WCHAR des [10]; lstrcpy(des,src); 

WCHAR ->double

Double des; WCHAR src[10]; swscanf(src,_T("%lf"),&des); 

double->CString

CString des double src des.Format(_T("%lf"), src); 

WCHAR ->int

Double des; WCHAR src[10]; swscanf(src,_T("%d"),&des); 

int ->CString

CString des double src des.Format(_T("%d"), src);  

char -> WCAHR

WCHAR WBuffer[BufferLength]; memset(WBuffer, 0,BufferLength); char * src =”abc”; int nLen = strlen(src) +1; int nwLen = MultiByteToWideChar(CP_ACP, 0, src,nLen, NULL, 0); MultiByteToWideChar(CP_ACP, 0, src, nLen, WBuffer, nwLen); //change char * to PWCHAR  

你可能感兴趣的:(null)