Pointer arithmetic
Chip Salzenberg
chip at tct.uucp
Tue Jan 8 03:47:57 AEST 1991
According to kdq at demott.COM (Kevin D. Quitt):
> The actual code is:
>
>
>const unsigned char *chars = "some string"
>unsigned char pass[];
>
> c = strchr( chars, toupper( pass[ i ]) ) - chars + 1;
>
>
> gcc would not accept this no matter what I did.
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.
--
Chip Salzenberg at Teltronics/TCT <chip at tct.uucp>, <uunet!pdn!tct!chip>
"If Usenet exists, then what is its mailing address?" -- me
"c/o The Daily Planet, Metropolis." -- Jeff Daiell
More information about the Comp.lang.c
mailing list