- Kod: Zaznacz cały
// Plik źródłowy np. Unit1.cpp.
//--------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
int iFileHandle;
int iFileLength;
int iBytesRead;
int iBytesWrite = 0;
char *pszBuffer;
if(OpenDialog1->Execute())
{
try
{
iFileHandle = FileOpen(OpenDialog1->FileName, fmOpenRead);
iFileLength = FileSeek(iFileHandle, 0, 2);
FileSeek(iFileHandle, 0, 0);
pszBuffer = new char[iFileLength+1];
iBytesRead = FileRead(iFileHandle, pszBuffer, iFileLength);
FileClose(iFileHandle);
while(iBytesWrite < iBytesRead)
{
if(pszBuffer[iBytesWrite] == 0)
pszBuffer[iBytesWrite] = ' ';
iBytesWrite++;
}
Memo1->Lines->SetText(pszBuffer);
delete [] pszBuffer;
}
catch(...)
{
Application->MessageBox("Can't perform one of the following file operations: Open, Seek, Read, Close.", "File Error", IDOK);
}
}
}
//--------------------------------
Na formie mam tylko memo1 i opendialog1
a błąd dotyczy tej linijki
Memo1->Lines->SetText(pszBuffer);
[BCC32 Error] Unit3.cpp(43): E2034 Cannot convert 'char *' to 'wchar_t *'
[BCC32 Error] Unit3.cpp(43): E2342 Type mismatch in parameter 'Text' (wanted 'wchar_t *', got 'char *')
jak zamienic ta zmienna ?