Re: A89: installing C Event Hooks + misc other...


[Prev][Next][Index][Thread]

Re: A89: installing C Event Hooks + misc other...




At 14:34 2001-02-13, you wrote:


> > while(s2[x]!=0 && s1[x]==s2[x])
> >   x++;
>
>darn, i am looking at your code an see a bug,
>the original function called strlen because either x had to == strlen(s2)
>or else the function must return NULL
>
>so either way, I think that one would need to loop through s2 up to two
>times...

no, that code wasn't complete. You used x to step through the string so why 
not using it to check the length too?
do a

return s2[x]==0?x:0;

and it will return the length of the string if you checked through all of it.
(if you did, it would break the loop when s2[x] is on the 
endofstring-marker, right?)

///Olle




Follow-Ups: References: