strcmp weird error?

Hey. I am getting an error in finding node in BST. Is there any difference betwee

if(strcmp(root->barcode,item.bar)<0) AND
if(strcmp(item.bar, root->barcode,)<0)

I dont get the error if I write first way but get not found when I write second way...
Well the second one has a stray comma after 'barcode' that would prevent it from compiling. But assuming that is a typo....

1
2
3
4
5
// this...
if( strcmp( a, b ) < 0 )

// is the same as this:
if( strcmp( b, a ) > 0 )


If the two strings are equal, strcmp will return 0.

If the first string is "less" than the second string (ie: the first mismatching character is less in the first string than the 2nd string), it will return a value less than 0

If the first string is "more" than the second string, it will return a value greater than 0.
Topic archived. No new replies allowed.