問題描述
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的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!