Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!apple!vsi1!wyse!mips!prls!philabs!phri!marob!daveh From: daveh@marob.masa.com (Dave Hammond) Newsgroups: comp.lang.c Subject: Re: In defense of scanf() (Re: Re^2: scanf(..)) Message-ID: <1989Jun17.121802.6327@marob.masa.com> Date: 17 Jun 89 12:18:02 GMT Reply-To: daveh@marob.masa.com (Dave Hammond) Organization: ESCC New York City Lines: 18 In article <824@cbnewsl.ATT.COM> mpl@cbnewsl.ATT.COM (michael.p.lindner) writes: >> > When filtering tabular data from files, .... >> >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. Not only that, since it delimits the returned token by replacing the terminating blank with a null, you are forced to work with a copy of the input line, if for some reason the complete line must survive the call to strtok(). I prefer using strpbrk(line, "\s\t\n") and either copying, or just peeking at the token, whichever is required. -- Dave Hammond daveh@marob.masa.com