The wonders of C

Baker paul at dual.UUCP
Tue Mar 19 07:21:06 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.

But then the whole point of C is to make it easy to commit errors which
superficially look correct, compile without a whimper and yet are totally
wrong.  For example "if (X!=1)" ... compiles just as well as "if (x|=1)".
On many terminals "|" and "!" are almost indistinguishable. "if (x<>1)
would have been incredibly easier to understand, but, oh no, other people
had used this and so was obviously unacceptable.

Paul Wilcox-Baker.



More information about the Comp.lang.c mailing list