Don't use Scanf()
Henry Spencer
henry at utzoo.uucp
Sun Mar 13 10:58:41 AEST 1988
> For example, if you want to print a string fast, you would write
> a routine that uses only putc...
!!NO!! If you want to print a string fast, you use fputs and insist that
your supplier implements it properly. Putc has to do things like buffer-
overflow checking on every character; a fast implementation of fputs can
inspect the buffer *once*, note that there is room for N more characters,
copy N characters at high speed, and then update counts and so forth *once*.
This is a major efficiency win over putc if you are doing it a lot.
Unfortunately, not all implementors make the effort to make stdio fast.
In general, System V stdios are fast and 4BSD ones are not. (There are
exceptions to this, both ways, and I believe the 4BSD one is going to be
improved.)
--
Those who do not understand Unix are | Henry Spencer @ U of Toronto Zoology
condemned to reinvent it, poorly. | {allegra,ihnp4,decvax,utai}!utzoo!henry
More information about the Comp.lang.c
mailing list