Visualizzazione dei risultati da 1 a 5 su 5

Discussione: [c++]LPCSTR eccc

  1. #1
    Utente di HTML.it
    Registrato dal
    Jun 2003
    Messaggi
    4,826

    [c++]LPCSTR eccc

    ciao.Cosa sono gli LPCSTR?
    che tipo è?
    come si converte da string a LPCSTR e viceversa?


    Ho notato che in microsoft esistono altre casistiche simili, variabili puntatori di qualche tipo che hanno un nome di classe diverso dal tipo(ad es string => LPCSTR).

    Grazie.

  2. #2
    Utente di HTML.it L'avatar di oregon
    Registrato dal
    Jul 2005
    residenza
    Roma
    Messaggi
    36,480
    Un LPCSTR equivale ad un

    const char *

    mentre un LPSTR equivale ad un

    char *
    No MP tecnici (non rispondo nemmeno!), usa il forum.

  3. #3
    Utente di HTML.it L'avatar di shodan
    Registrato dal
    Jun 2001
    Messaggi
    2,381
    LPCSTR == const char*
    LPCWSTR == const wchar_t*
    LPCTSTR == const TCHAR*
    ne più ne meno.
    This code and information is provided "as is" without warranty of any kind, either expressed
    or implied, including but not limited to the implied warranties of merchantability and/or
    fitness for a particular purpose.

  4. #4
    Utente di HTML.it L'avatar di KrOW
    Registrato dal
    Feb 2009
    Messaggi
    281
    Un LPCSTR non è altro che un const char* (se unicode non è definito).
    Detto questo potresti convertire una string in un LPCSTR con il metodo c_str()
    di string...

    Come non detto

  5. #5
    Riesumo uno schema che avevo scritto ai tempi:
    codice:
    LP[C][T|W]STR
    LP = puntatore (teoricamente basterebbe P, L è un relitto dei tempi dei 16 bit)
    C = se c'è significa che è costante
    W = se c'è significa che è una stringa Unicode (basata su wchar_t)
    T = se c'è significa che è una stringa TCHAR (ANSI o Unicode a seconda di come è impostata la macro _UNICODE)
    se non c'è ne W né T la stringa è ANSI
    STR = stringa
    
    Quindi:
    LPSTR		char *
    LPCSTR		const char *
    LPTSTR		TCHAR *
    LPCTSTR		const TCHAR *
    LPWSTR		wchar_t *
    LPCWSTR		const wchar_t *
    .
    Amaro C++, il gusto pieno dell'undefined behavior.

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.