how has C bitten you?
Bennett E. Todd III
bet at ecsvax.UUCP
Wed Aug 7 04:46:16 AEST 1985
In article <243 at ecrhub.UUCP> david at 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 at tucc.BITNET
More information about the Comp.lang.c
mailing list