In defense of scanf() (Re: Re^2: scanf(..))

michael.p.lindner mpl at cbnewsl.ATT.COM
Fri Jun 16 23:36:47 AEST 1989


In article <4563 at ficc.uu.net>, peter at ficc.uu.net (Peter da Silva) writes:
> In article <3145 at buengc.BU.EDU>, bph at buengc.BU.EDU (Blair P. Houghton) writes:
> > When filtering tabular data from files, ....
> > .... scanf is
> > suited ideally.
>
> I tend to stick with strspn() and strtok(), myself.
>
> Peter da Silva, Xenix Support, Ferranti International Controls Corporation.

Hope you never have to do anything complex.  If you call strtok on e string
in the middle of a strtok of another string it trashes its state information
on the first string (a little known feature), which can cause extremely
elusive bugs.  My previous project got stuck with this when we started using
some library code which called it.  For this reason, I avoid strtok like the
plague in all but the simplest applications.

Mike Lindner
attunix!mpl



More information about the Comp.lang.c mailing list