Board index » cppbuilder » Re: Is any difference in effectiveness between memcmp() and strncmp()?

Re: Is any difference in effectiveness between memcmp() and strncmp()?


2006-08-18 12:44:00 AM
cppbuilder2
Ed Mulroy wrote:
Quote
I told you of a situation in which your way of doing things may fail. Your
reply contains an example whose data is specifically constructed to avoid
that situation.
His reply contains an example whose data is specifically constructed to
reproduce the situation he said he has in his program. If you reread
his post from around 10:49 Eastern time, I think you'll find that your
objection, while valid in general, doesn't really apply to this case.
--
Gillmer J. Derge [TeamB]
 
 

Re:Re: Is any difference in effectiveness between memcmp() and strncmp()?

Vladimir Grigoriev wrote:
Quote
Looking through machine code of strncmp() and memcmp() generated for BCB 5.0
I did not see "extra work". I think all depends of concrete platform and
function realization.

Vladimir Grigoriev
Are the bytes treated as signed or unsigned? I would think that memcmp
would treat the bytes as unsigned, so that a value of 0x80 would be
greater than 0x7F, but what about strncmp?
-Eliot
 

Re:Re: Is any difference in effectiveness between memcmp() and strncmp()?

From the BCB 5 Help:
"...strncmp makes the same unsigned comparison as strcmp, but looks at no
more than maxlen characters."
Vladimir Grigoriev
"Eliot Frank" < XXXX@XXXXX.COM >wrote in message
Quote

Are the bytes treated as signed or unsigned? I would think that memcmp
would treat the bytes as unsigned, so that a value of 0x80 would be
greater than 0x7F, but what about strncmp?

-Eliot
 

{smallsort}

Re:Re: Is any difference in effectiveness between memcmp() and strncmp()?

Ed, I have not understood the situation you told. Please show a code
example. Take into account that *n* (count of bytes to compare) does not
exceed the maximum of two string lengths. At least one string have a length
that greater than *n*.
Vladimir Grigoriev
"Ed Mulroy" < XXXX@XXXXX.COM >wrote in message
Quote
Why did you post that?

I told you of a situation in which your way of doing things may fail.
Your
reply contains an example whose data is specifically constructed to avoid
that situation.

. Ed