字符類型間的轉換:
1、LPCWSTR->wchar_t *;LPCSTR ->char *;LPCWSTR->const wchar_t *;
2、string ->LPWSTR L"字符串"
3、_T("字符串")變char->LPCSTR
4、CString -> LPWSTR:
use MultiByteToWideChar
CString astring("ssss");
LPWSTR pointer;
pointer=(LPWSTR)(LPCTSTR)astring;
5、LPWSTR -> CString:
LPWSTR s; CString cs = s;
6-1、int->char *:
char t[];int n;
sprintf(t,“%d”,n);
6-2、char *->int
char *s="11";int x;
x=atoi(s);
7-1、char []->CString
char code[10];CString m_str;
m_str.Format("%s",code);
7-2、CString-》char []
CString s1="ad";char s2[256];
strcpy(s2,s1);
8、CString-》void *
(void*)LPCTSTR(buf)
9、CString-》char *
a、(LPSTR)(LPCTSTR)str
b、str.GetBuffer();
10-1、int -》CString
CString str="12";int Id=10;
str.Format("%s%d", str, Id);
10-2、CString-》int
Id=atoi(str);