home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!howland.reston.ans.net!usc!cs.utexas.edu!torn!csd.unb.ca!news.ucs.mun.ca!femto.engr.mun.ca!bibhas
- From: bibhas@femto.engr.mun.ca (Bibhas Bhattacharya)
- Subject: Re: strtok
- Message-ID: <bibhas.725836376@femto.engr.mun.ca>
- Sender: usenet@news.ucs.mun.ca (NNTP server account)
- Organization: Memorial University of Newfoundland
- References: <1992Dec31.045902.2025@mcs.drexel.edu>
- Distribution: usa
- Date: Thu, 31 Dec 1992 21:12:56 GMT
- Lines: 28
-
- tjhendry@mcs.drexel.edu (Jonathan Hendry) writes:
-
- >Hi. Could someone please email me a brief description of how to use
- >strtok()? I have read a few books, and asked my coworkers, and haven't
- >received much useful information.
-
- >Namely, after I run it on a string once, how do I get to the next
- >part of the string?
-
- It's worth noting that the string returned by strtok is not a fresh copy
- but a part of the fragmented original string. Which means:
- - If you're going to refill the original string and want to use
- the returend string later, better make a copy of the returned
- string somewhere.
- gets(line);
- tok = strtok(line,":");
- gets(line); /*refill*/
- /*guess what? tok is not what you think it is, anymore*/
-
- - As strtok operates on a string it keeps on fragmenting it. If you want
- to do anything with original string again, you must keep a copy of it.
-
- Bibhas.
- --
- +==========================+=========================+
- | login name: DR. Jackyl | In real life: Mr. Hyde.|
- +==========================+=========================+
- bibhas@pico.engr.mun.ca
-