C Community's Cavalier Attitude On Software Reliability

Karl Heuer karl at haddock.ima.isc.com
Thu Mar 1 07:30:07 AEST 1990


In article <2922 at goanna.oz.au> ok at goanna.oz.au (Richard O'keefe) writes:
>karl at haddock.ima.isc.com (Karl Heuer) wrote:
>>Fixed in ANSI C, via the "%n" directive.
>
>It is a great improvement that this is possible, but it really doesn't
>count as "DIRECTLY determinable".

A quibble.

>One very simple change would have done:  _add_ a new suppression
>character, say "#".  %#<fmt> would act exactly like %*<fmt> except
>that it would be counted.

My own idea was to add a new format *specifier*, say "%;", whose whole purpose
would be to increment the return value.  This is a conceptually simpler
change, and is equally powerful (your "%#d" is my "%*d%;", and you don't need
to play around with zero-width fields if the increment is all you want).  Note
also that the typical use would be to put a single "%;" at the end of the
format, to verify that the whole thing worked (which can also be done with
"%n"); normally one doesn't care about partial success.

>Presumably the ANSI C committee considered and rejected some such proposal.

I believe it was generally recognized that scanf() is a crock which continues
to exist only for backward compatibility.

>It doesn't bother me, because [it's usually better not to use scanf anyway]

Agree.

Karl W. Z. Heuer (karl at ima.ima.isc.com or harvard!ima!karl), The Walking Lint



More information about the Comp.lang.c mailing list