home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_10_12 / 1012076a < prev    next >
Text File  |  1992-10-13  |  551b  |  36 lines

  1. /* token1.c:    Parse input strings into tokens */
  2.  
  3. #include <stdio.h>
  4. #include <string.h>
  5.  
  6. main()
  7. {
  8.     char s[81], *break_set =
  9.       " \t\n\f\v\\\"~!@#$%^&*()-_=+`'[]{}|;:/?.,<>";
  10.     
  11.     while (gets(s))
  12.     {
  13.         char *tokp, *sp = s;
  14.         
  15.         while ((tokp = strtok(sp,break_set)) != NULL)
  16.         {
  17.             puts(tokp);
  18.             sp = NULL; /* continue in this string */
  19.         }
  20.     }
  21.     return 0;
  22. }
  23.  
  24. Input
  25. -----
  26. This is 1just2a3test#.
  27. Good-bye.
  28.  
  29. Output
  30. ------
  31. This
  32. is
  33. 1just2a3test
  34. Good
  35. bye
  36.