char* __fastcall TForm1::read_Ch(AnsiString name_File, int f_Size)
{
char *znaki=new char[f_Size];
FILE* fp;
fp=fopen(name_File.c_str(),"r");
for(int i=0;i<f_Size;i++)
fscanf(fp,"%c",&znaki[i]);
fclose(fp);
return znaki;
}
void __fastcall TForm1::init_Memo(AnsiString name_File, int f_Size)
{
Memo1->Lines->Append(AnsiString(read_Ch(name_File,f_Size)));
}
int __fastcall TForm1::sum_Txt(char *phrase)
{
int sum=0,i,count=Memo1->Lines->Count;
AnsiString *buff=new AnsiString[count];
for(i=0;i<count;i++)
{
buff[i]=Memo1->Lines->Text[i];
if(strcmp(buff[i].c_str(),phrase))
++sum;
}
delete buff;
return sum;
}
void __fastcall TForm1::Button1Click(TObject *Sender)
{
AnsiString path;
path="C:\\Users\\Public\\Documents\\Embarcadero\\Studio\\18.0\\GetItInstall.log";
init_Memo(path,2048);
AnsiString temp=Edit1->Text;
int how_Many=sum_Txt(temp.c_str());
Label1->Caption=IntToStr(how_Many);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
Close();
}
Brak komentarzy:
Prześlij komentarz