Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site ecsvax.UUCP Path: utzoo!linus!philabs!prls!amdimage!amdcad!decwrl!decvax!mcnc!ecsvax!bet From: bet@ecsvax.UUCP (Bennett E. Todd III) Newsgroups: net.lang.c Subject: Re: how has C bitten you? Message-ID: <123@ecsvax.UUCP> Date: Tue, 6-Aug-85 14:46:16 EDT Article-I.D.: ecsvax.123 Posted: Tue Aug 6 14:46:16 1985 Date-Received: Sat, 10-Aug-85 20:44:46 EDT References: <302@brl-tgr.ARPA> <4081@alice.UUCP> <243@ecrhub.UUCP> Reply-To: bet@ecsvax.UUCP (Bennett E. Todd III) Distribution: net Organization: Duke University Computation Center Lines: 36 In article <243@ecrhub.UUCP> david@ecrhub.UUCP (David M. Haynes) writes: >One of my all time favourites is the non-orthagonality between >scanf and printf. Especially the following: > > scanf("%D %F", long, double); or > scanf("%ld %lf", long, double); >vs. > printf("%ld %f", long, double); Interesting. The mismatch in formatting arguments was something I had never noticed; I was always amused by this one instance where C's call-by-value catches every C programmer, at least once. (I have never heard anybody claim to have never been bitten by this one -- and it's worst for those who had heard of it before it bit them.) printf("%d", i); seems to cause people to want to try scanf("%d", i); After you have been bitten once or twice you get really paranoid about making sure you pass the *address* of i, not its value: scanf("%d", &i); I am certain that this belongs on the list of all-time most popular blunders. -Bennett -- "Some people are lucky; the rest of us have to work at it." Bennett Todd -- Duke Computation Center, Durham, NC 27706-7756; (919) 684-3695 ...{decvax,seismo,philabs,ihnp4,akgua}!mcnc!ecsvax!bet or dbtodd@tucc.BITNET