PDA

Просмотр полной версии : как избавиться от бага


nJsk
25.02.2008, 14:21
есть ексампл от оброботки файлов именно считывание что мне зделать что-бы он пошол прототип функции куда-то впоять или что
The following example uses a button, a string grid, and an Open dialog box on a form. When the button is clicked, the user is prompted for a filename. When the user clicks OK, the specified file is opened, read into a buffer, and closed. Then the buffer is displayed in two columns of the string grid. The first column contains the character values in the buffer. The second column contains the numeric values of the characters in the buffer.

void __fastcall TForm1::Button1Click(TObject *Sender)

{
int iFileHandle;
int iFileLength;
int iBytesRead;
char *pszBuffer;
if (OpenDialog1->Execute())
{
try
{
iFileHandle = FileOpen(OpenDialog1->FileName, fmOpenRead);
iFileLength = FileSeek(iFileHandle,0,2);
FileSeek(iFileHandle,0,0);
!!pszBuffer = newchar[iFileLength+1];!!
iBytesRead = FileRead(iFileHandle, pszBuffer, iFileLength);
FileClose(iFileHandle);

for (int i=0;i<iBytesRead;i++)
{
StringGrid1->RowCount += 1;
StringGrid1->Cells[1][i+1] = pszBuffer[i];
StringGrid1->Cells[2][i+1] = IntToStr((int)pszBuffer[i]);
}
delete [] pszBuffer;
}
catch(...)
{
Application->MessageBox("Can't perform one of the following file operations: Open, Seek, Read, Close.", "File Error", IDOK);
}
}
}
а именно не нраветься строка находяшая в воскрицательных знаках пишет [C++ Error] Unit2.cpp(38): E2451 Undefined symbol 'newchar'
помогите пожалуйсто зарание спасибо

k0t_
27.02.2008, 16:36
pszBuffer = new char[iFileLength+1];