Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!att!cbnewsl!mpl From: mpl@cbnewsl.ATT.COM (michael.p.lindner) Newsgroups: comp.lang.c Subject: Re: In defense of scanf() (Re: Re^2: scanf(..)) Summary: strtok considered dangerous by author Message-ID: <824@cbnewsl.ATT.COM> Date: 16 Jun 89 13:36:47 GMT References: <225800176@uxe.cso.uiuc.edu> <11831@bloom-beacon.MIT.EDU> <4563@ficc.uu.net> Organization: AT&T Bell Laboratories Lines: 19 In article <4563@ficc.uu.net>, peter@ficc.uu.net (Peter da Silva) writes: > In article <3145@buengc.BU.EDU>, bph@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