The D Programming Language
Scott Daniels
daniels at teklds.TEK.COM
Sat Mar 12 11:56:28 AEST 1988
In article <587 at bms-at.UUCP> stuart at bms-at.UUCP (Stuart D. Gathman) writes:
>Another example is string comparison. I use a string compare function
>that returns the index of the first different character. I also
>need the gt/lt/eq result. Fortunately, in this case it is easily
>computed by recomparing the chars at the index.
An alternative is the string comparison I normally use:
cmpstr(s1,s2)
0: if equal
>0: if s1 > s2
<0: if s1 < s2
abs(cmpstr(s1,s2)) is the number of chars compared:
s1[ abs(cmpstr(s1,s2))-1 ] != s2[ abs(cmpstr(s1,s2))-1 ]
if cmpstr did not return 0. Normally this function returns just
about any information I need, and it is usually not very hard to
make an extremely fast version in assembly.
-Scott Daniels (daniels at teklds.TEK.COM)
More information about the Comp.lang.c
mailing list