45fan.com - 路饭网

搜索: 您的位置主页 > 网络频道 > 阅读资讯:lpcstr与lpctstr的区别在哪?

lpcstr与lpctstr的区别在哪?

2016-09-07 01:59:26 来源:www.45fan.com 【

lpcstr与lpctstr的区别在哪?

LPCSTR A 32-bit pointer to a constant character string.
LPSTR A 32-bit pointer to a character string.
LPCTSTR A 32-bit pointer to a constant character string that is portable for Unicode and
DBCS.
LPTSTR A 32-bit pointer to a character string that is portable for Unicode and DBCS
LPWSTR 就是wchar*是支持unicode等双字节的字符是16bits
LPSTR 是char*是ansi单子节8bits
LPCTSTR 是const char*
LPTSTR 是一个宏
#ifdef _UNICODE
#define LPTSTR LPWSTR
#else
#define LPTSTR LPSTR
#endif
也就是说当你定义了_UNICODE宏LPTSTR就是LPWSTR
没有定义_UNICODE,LPTSTR就是LPSTR
可以用ATL的W2T,T2W,W2A,A2W,A2T,T2A六个宏转换
char s[20]是20个字节的数组
而char *s只是一个指针他只有16/32/64位字节
从这个意义上char s[20] 相当于 char *s = new char[20];
他们分配内存的位置也不同,特别当char s[20]是全局变量时。
char s[20] 不等于 char *s = new char[20] 了。
 

本文地址:http://www.45fan.com/a/question/73409.html
Tags: lpcstr lpctstr
编辑:路饭网
相关文章列表
关于我们 | 联系我们 | 友情链接 | 网站地图 | Sitemap | App | 返回顶部