home *** CD-ROM | disk | FTP | other *** search
- Organization: Applications Software, Carnegie Mellon, Pittsburgh, PA
- Path: sparky!uunet!cis.ohio-state.edu!news.sei.cmu.edu!fs7.ece.cmu.edu!crabapple.srv.cs.cmu.edu!andrew.cmu.edu!rr2p+
- Newsgroups: comp.lang.c
- Message-ID: <kf4GU6q00VQsM3GGYU@andrew.cmu.edu>
- Date: Mon, 23 Nov 1992 13:50:46 -0500
- From: Richard Dale Romero <rickr+@CMU.EDU>
- Subject: Re: Multiple &'s in an if statement
- In-Reply-To: <1992Nov23.164530.19214@iacd>
- References: <1992Nov23.164530.19214@iacd>
- Distribution: comp.lang.c
- Lines: 17
-
- Probably because you're using bit-wise and instead of logical and.
- In C, a zero is false and anything else is true. There is no specification
- for what (x == y) returns other than zero or not zero. So, suppose
- that isdigit returns a 2 everytime for true, and
- (iscntrl(name[(strlen(path) + 5)]))
- returns a 1. Their bitwise and is 0, ie, false.
-
- So, to make it work, just do the following:
-
- if(( isdigit[i] & isdigit[i+1] & isdigit[i+2] & isdigit[i+3] & isdigit[i+4])
- && (name[(strlen(path)+5)] == NULL)) {
- ...
- }
-
- -rick
-
-
-