I have the following code:
for( CarsPool::CarRecord &record : recs->GetRecords()) { LVITEM item; item.mask = LVIF_TEXT; item.cchTextMax = 6; item.iSubItem = 0; item.pszText = (LPSTR)(record.getCarName().c_str()); //breakpoint on this line. item.iItem = 0; ListView_InsertItem(CarsListView, &item); item.iSubItem = 1; item.pszText = TEXT("Available"); ListView_SetItem(CarsListView, &item); item.iSubItem = 2; item.pszText = (LPSTR)CarsPool::EncodeCarType(record.getCarType()); ListView_SetItem(CarsListView, &item); }
Information from Visual Studio Debugger is here:

Why can't a program read characters from a string?
The test showed me that it works as follows:
MessageBox(hWnd, (LPSTR)(record.getCarName().c_str()), "Test", MB_OK);
source share