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

Peter da Silva peter at ficc.uu.net
Sun Jul 23 01:05:16 AEST 1989


In article <824 at cbnewsl.ATT.COM>, mpl at cbnewsl.ATT.COM (michael.p.lindner) writes:
> In article <4563 at ficc.uu.net>, peter at ficc.uu.net (Peter da Silva) writes
  about scanf:
> > I tend to stick with strspn() and strtok(), myself.

> 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.

Sounds like something too fancy for scanf, too. But thanks for the info... I've
never gotten that complex with strtok. By that time I'm usually stepping
through the string by hand (while (strchr(*s, legalchars)) s++;)...

[files away information that there are broken implementations of strtok...]
-- 
Peter da Silva, Xenix Support, Ferranti International Controls Corporation.

Business: uunet.uu.net!ficc!peter, peter at ficc.uu.net, +1 713 274 5180.
Personal: ...!texbell!sugar!peter, peter at sugar.hackercorp.com.



More information about the Comp.lang.c mailing list