MFC类型转换

目录

CString 转 char*

“文本内容” 转 CString

char* 转 CString(直接赋值)

int 转CString

float 转 CString

double 转CString


CString 转 char*

char *chr;
CString cstr;
chr = (char*)(LPCTSTR)cstr;

“文本内容” 转 CString

CString cstr;
cstr = _T("文本内容");

char* 转 CString(直接赋值)

char* chr;
CString cstr;
cstr = chr;

int 转CString

int x;
CString cstr;
cstr.Format(_T("%d"), x);

float 转 CString

float x;
CString cstr;
cstr.Format(_T("%f"), x);

double 转CString

double x;
CString cstr;
cstr.Format(_T("%lf"), x);

你可能感兴趣的:(MFC,mfc,c++)