Xref: utzoo comp.lang.c:35090 comp.lang.c++:11030 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!pdn!tscs!tct!chip From: chip@tct.uucp (Chip Salzenberg) Newsgroups: comp.lang.c,comp.lang.c++ Subject: Re: Pointer arithmetic Message-ID: <2788A63D.A86@tct.uucp> Date: 7 Jan 91 16:47:57 GMT References: <1991Jan5.001607.5915@demott.com> Organization: Teltronics/TCT, Sarasota, FL Lines: 22 According to kdq@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 , "If Usenet exists, then what is its mailing address?" -- me "c/o The Daily Planet, Metropolis." -- Jeff Daiell