LPCSTR, LPCTSTR and LPTSTR(LPCSTR、LPCTSTR 和 LPTSTR)
问题描述
LPCSTR、LPCTSTR 和 LPTSTR 有什么区别?
What the difference between LPCSTR, LPCTSTR and LPTSTR?
为什么我们需要这样做将字符串转换为LV/_ITEM结构变量pszText:
Why do we need to do this to convert a string into a LV / _ITEM structure variable pszText:
LV_DISPINFO dispinfo;
dispinfo.item.pszText = LPTSTR((LPCTSTR)string);
推荐答案
回答您问题的第一部分:
To answer the first part of your question:
LPCSTR 是一个指向 const 字符串的指针(LP 表示 Long指针)
LPCSTR is a pointer to a const string (LP means Long Pointer)
LPCTSTR 是一个指向 const TCHAR 字符串的指针,(TCHAR 是宽字符还是字符取决于 UNICODE 是否在你的项目)
LPCTSTR is a pointer to a const TCHAR string, (TCHAR being either a wide char or char depending on whether UNICODE is defined in your project)
LPTSTR 是一个指向(非常量)TCHAR 字符串
LPTSTR is a pointer to a (non-const) TCHAR string
在实践中,过去在讨论这些时,为了简单起见,我们省略了指向 a 的指针"短语,但正如 lightness-races-in-orbit 所述,它们都是指针.
In practice when talking about these in the past, we've left out the "pointer to a" phrase for simplicity, but as mentioned by lightness-races-in-orbit they are all pointers.
这是一篇很棒的 codeproject 文章,描述了 C++ 字符串(参见 2/3比较不同类型的图表的下降方式)
This is a great codeproject article describing C++ strings (see 2/3 the way down for a chart comparing the different types)
这篇关于LPCSTR、LPCTSTR 和 LPTSTR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:LPCSTR、LPCTSTR 和 LPTSTR
基础教程推荐
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
- 我应该对 C++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
- CString 到 char* 2021-01-01
- 初始化列表*参数*评估顺序 2021-01-01
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
- 通过引用传递 C++ 迭代器有什么问题? 2022-01-01
