MFC---类型之转换.docVIP

  • 9
  • 0
  • 约2.16万字
  • 约 23页
  • 2018-05-04 发布于河南
  • 举报
MFC---类型之转换.doc

1、CString to char* 经过类型强制转换,可以将CString类型转换成char*,例如: CString cStr = Hello,world!; char* zStr = (char*)(LPCTSTR)cStr; 2、char* to CString char*类型可以直接给CString,完成自动转换,例如: char* zStr = Hello,world!; CString cStr = zStr; 3、CString to LPCSTR 将CString转换成LPCSTR,需要获得CString的长度,例如: CString cStr = _T(Hello,world!); int nLen = cStr.GetLength(); LPCSTR lpszBuf = cStr.GetBuffer(nLen); 4、CString to LPSTR 这个和第3个技巧是一样的,例如: CString cStr = _T(Hello,world!); int nLen = str.GetLength(); LPSTR lpszBuf = str.GetBuffer(nLen); 5、Char[] to int 将字符串类型转换成整数型,可以使用atoi函数,例如: char c[10]; int n; n =

文档评论(0)

1亿VIP精品文档

相关文档