1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
void __fastcall TForm1::Button2Click(TObject *Sender)
{
test->Clear();
TListItem *item;
TStringList *sl = new TStringList();
sl->LoadFromFile( "test.txt" );
char *date;
char *ip;
char *mac;
int nb = test->Items->Count;
int nbdoublons = 0;
for( int i=0; i < sl->Count; i++ )
{
if (test->Items->Count ==0) {
item = test->Items->Add();
AnsiString l= sl->Strings[i];
date = strtok(l.c_str(), ";");
item->Caption = date;
ip = strtok(NULL, ";");
item->SubItems->Add(ip);
mac = strtok(NULL, ";");
item->SubItems->Add(mac);
nb++;
}
else
{
for(int k=0; k < nb ; k++)
{
TListItem *Item = test->Items->Item[k] ;
ShowMessage(mac); // => 18:A9:05:B2:C6:D au lieu de 18:A9:05:B2:C6:4D
AnsiString NumListe =Item->SubItems->Strings[1]; // adresse mac : 18:A9:05:B2:C6:4D
if (mac == NumListe)
{
int nbdoublons = nbdoublons++;
}
else
{
item = test->Items->Add();
AnsiString l= sl->Strings[i];
date = strtok(l.c_str(), ";");
item->Caption = date;
ip = strtok(NULL, ";");
item->SubItems->Add(ip);
mac = strtok(NULL, ";");
item->SubItems->Add(mac);
}
}
}
}
delete sl ;
} |
Partager