home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / c / 19091 < prev    next >
Encoding:
Text File  |  1992-12-31  |  1.2 KB  |  35 lines

  1. Path: sparky!uunet!spool.mu.edu!agate!usenet.ins.cwru.edu!po.CWRU.Edu!rat
  2. From: rat@po.CWRU.Edu (Reza A. Tabib-Azar)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: strtok
  5. Date: 31 Dec 1992 20:39:37 GMT
  6. Organization: Case Western Reserve University, Cleveland, OH (USA)
  7. Lines: 22
  8. Message-ID: <1hvlq9INNjpm@usenet.INS.CWRU.Edu>
  9. References: <1992Dec31.045902.2025@mcs.drexel.edu>
  10. Reply-To: rat@po.CWRU.Edu (Reza A. Tabib-Azar)
  11. NNTP-Posting-Host: slc12.ins.cwru.edu
  12.  
  13.  
  14. In a previous article, tjhendry@mcs.drexel.edu (Jonathan Hendry) says:
  15.  
  16. >Hi. Could someone please email me a brief description of how to use
  17. >strtok()? I have read a few books, and asked my coworkers, and haven't
  18. >received much useful information.
  19. >
  20. >Namely, after I run it on a string once, how do I get to the next
  21. >part of the string?
  22. >
  23.  
  24. You have to call it with that NULL as the string.
  25.         token = strtok( str,  ",\n " );
  26.         token = strtok( NULL, ",\n " );
  27. You can call the secend line in a loop and check token to see if it is NULL,
  28. if it is null then you have all your tokens.
  29. I hope this will help.
  30.  
  31. -- 
  32. main() { printf("\t\tReza A. Tabib-Azar\b\n"); 
  33.        printf("Life is real, unless declared an integer.\n");
  34.   printf("I get 'CoreDumped', therefore I am.\n", "\t\t\t\tAnonymous\n"); }
  35.