Pointer arithmetic

Kevin D. Quitt kdq at demott.com
Thu Jan 10 05:54:24 AEST 1991


In article <2788A63D.A86 at tct.uucp> chip at tct.uucp (Chip Salzenberg) writes:
>If strchr() wasn't declared properly, gcc would complain.
>
>But a more serious complaint is the lack of a check on the return
>value of strchr().  It might be NULL, after all, in which case the
>subtraction will send the resulting value into deep space.

    As I indicated, strchr was not being declared; it's not declared in
the same include file as with Microsoft C.  I'm used to compilers that
complain when things are declared, so I'm used to silence as being a
sign that everything's OK.  And you're right about checking the return
value. 

    This code is a fragment from an encryption package, which is why I
had to change it to ask my question.  When I get to the line with
strchr, I have already guaranteed that the search will not fail.

-- 
 _
Kevin D. Quitt         demott!kdq   kdq at demott.com
DeMott Electronics Co. 14707 Keswick St.   Van Nuys, CA 91405-1266
VOICE (818) 988-4975   FAX (818) 997-1190  MODEM (818) 997-4496 PEP last



More information about the Comp.lang.c mailing list