I've got 2 lists that I'm comparing (attached).
If I do a straight strcmp it shows a match which bsearch is not finding.
I've attached the code file. It's a bit complex. It's a derivitive of something that Salem wrote for me.
It's missing on
hornypotter.com and on
www.herbsbuy.com
It finds 8 out of 10 and I can't figure out for the life of me why it consistently misses on those 2.
Again, a straight strcmp shows a match in the x loop below.
the bsearch right below it misses on those 2.
The function in question is main. It is intended to be used as a dll.
The problem is in the code starting on line: 272.
You can see the problem by running it and seeing that it deletes 8 records from UTest.txt instead of the 10 that it should.
Any ideas as to what the problem might be?
Does bsearch provide inconsistent results?
The commandline run should be SLSSeoUrlFunc MTest.txt UTest.txt UUTest.txt
Code:
//Shows a match on the 2 URLs in question.
for ( int i = 0 ; i < nUpdate ; i++ )
{
for ( int x = 0 ; x < nUnknown ; x++ )
{
printf("\n%s : %s : %d", dbUpdate[i].base_url, dUnknown[x].base_url, strcmp(dbUpdate[i].base_url, dUnknown[x].base_url));
}
}
//Misses on the 2 URLs in question.
for ( int i = 0 ; i < nUpdate ; i++ )
{
db_st *f = bsearch(&dbUpdate[i], dUnknown, nUnknown, sizeof(*dUnknown), sortfn );
if ( f )
{
strcpy((*f).base_url,"");
}
}