E
ebc
Hi,
I have written a function that removes double entries from a sorted
array.
See the structures
typedef struct tagRECR
{
char name[LEN_NAME+1];
}
REC;
// the REC structure is filled dynamic (malloc...)
typedef struct tagTAB
{
int count; // count of itemes in lief
REC *lief; // dynamic generated list
// belegte anz Eintr,,ge
}
TAB;
Now the function
void removedoubleentries( TAB *tab )
{
int i,j;
RECL *source;
RECL *dest;
BOOL found;
source = tab->lief;
dest = source;
j=0;
found = FALSE;
for (i = 0; i < tab->count-1; i ++ )
{
if ( strcmp ( (source+i)->name, (source+1+i)->name) !=0 )
{
*(dest+j) = *(source+i);
j++;
found = FALSE;
}
else
found = TRUE;
}
// Now I am not sure if this is correct
// for the last entrie
*(dest+j) = *(source+i);
j++;
tab->count = j;
}
ebc
I have written a function that removes double entries from a sorted
array.
See the structures
typedef struct tagRECR
{
char name[LEN_NAME+1];
}
REC;
// the REC structure is filled dynamic (malloc...)
typedef struct tagTAB
{
int count; // count of itemes in lief
REC *lief; // dynamic generated list
// belegte anz Eintr,,ge
}
TAB;
Now the function
void removedoubleentries( TAB *tab )
{
int i,j;
RECL *source;
RECL *dest;
BOOL found;
source = tab->lief;
dest = source;
j=0;
found = FALSE;
for (i = 0; i < tab->count-1; i ++ )
{
if ( strcmp ( (source+i)->name, (source+1+i)->name) !=0 )
{
*(dest+j) = *(source+i);
j++;
found = FALSE;
}
else
found = TRUE;
}
// Now I am not sure if this is correct
// for the last entrie
*(dest+j) = *(source+i);
j++;
tab->count = j;
}
ebc