LPCSTR,LPCTSTR和LPTSTR [英] LPCSTR, LPCTSTR and LPTSTR

查看:230
本文介绍了LPCSTR,LPCTSTR和LPTSTR的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

LPCSTRLPCTSTRLPTSTR有什么区别?

为什么需要执行此操作以将字符串转换为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);

推荐答案

回答问题的第一部分:

LPCSTR是指向const字符串的指针(LP表示长指针 )

LPCSTR is a pointer to a const string (LP means Long Pointer)

LPCTSTR是指向const TCHAR字符串的指针(TCHAR是宽字符还是char,具体取决于您的项目中是否定义了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

在过去的实践中,为简单起见,我们省略了指向"的指针,但正如lightness-races-or-bit所提到的,它们都是指针.

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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆