The wonders of C
Wayne Berke
berke at csd2.UUCP
Fri Mar 22 12:47:00 AEST 1985
> > > I was reading Creative Computing when I saw the most bogus C programming
> > > example. The author was comparing C to Basic-
> > > Basic: if A=1 and B=1 goto 104950393040 [:->
> > > C: if (A==1 & B==1) foobar();
> > > Which works, of course, but it was clear from the context that the author
> > > thought that '&' and logical AND were identical!!!! -- Mark Roddy
> >
> > It doesn't work if A == 1 and B == 3. It calls foobar when it shouldn't.
It sure does work. It simplifies to
if (1==1 & 3==1) foobar()
if (TRUE & FALSE) foobar()
if (0x1 & 0x0) foobar()
if (FALSE) foobar()
So foobar is correctly not invoked.
More information about the Comp.lang.c
mailing list