LPCSTR

LPCSTR

LPCSTR是Win32和VC++所使用的一種字元串數據類型。LPCSTR被定義成是一個指向以'\0'結尾的常量字元的指針。

英文解釋


A 32-bit pointer to a character string that is portable for Unicode and DBCS.

中文解釋


L表示long指針
P表示這是一個指針
C表示是常量const
STR表示這個變數是一個字元串

轉換


轉換成CString
LPCSTR lpStr = "test";
CString str(lpStr);
CString反轉換
CString str(_T("test"));
LPCSTR lpStr = (LPCSTR)str;

C語言中使用


是以零結尾的字元串指針,相當於CHAR *。例子:
vuser_init() {
LPCSTR server;
LPCSTR user = "tomh";
LPCSTR password = "pwd";
LPCSTR connect[10];
server=lr_get_attrib_string("host");
if (server==NULL){
lr_error_message("Failed to login. Unknown host.\n");
return(0);
}