No buono... quel cast a (const char *) "a pedate" è una pessima idea, dato che, se il tuo progetto viene compilato in modalità Unicode, ti nasconde un errore fondamentale (ovvero, staresti passando un const wchar_t * ad una funzione che si aspetta un const char *).Originariamente inviato da DarthSandr
Grazie a tutti.
Alla fine ho risolto in modo simile a questo:
codice:LPCTSTR l1 = "str1"; LPCTSTR l2 = "str2"; char s[256] = ""; strcat(s, (const char *)l1); strcat(s, (const char *)l2); LPCTSTR final = s;
In generale, se usi le LP(C)TSTR, devi usare i generic text mappings dappertutto:
Rileggi il secondo link del mio post precedente.codice:LPCTSTR l1 = _T("str1"); LPCTSTR l2 = _T("str2"); TCHAR s[256] = ""; _tcscat(s, l1); _tcscat(s, l2); LPCTSTR final = s;
Che ovviamente non funziona, visto che è una stringa costante.Quando dava errore passavo gli LPCTSTR anche nel primo parametro della strcat.