home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / unix / aix / 9510 < prev    next >
Encoding:
Text File  |  1992-09-09  |  1.8 KB  |  80 lines

  1. Path: sparky!uunet!haven.umd.edu!darwin.sura.net!spool.mu.edu!sol.ctr.columbia.edu!emory!athena.cs.uga.edu!shen
  2. From: shen@athena.cs.uga.edu (Mingzuo Shen)
  3. Newsgroups: comp.unix.aix
  4. Subject: xlc does not like strtok()?
  5. Message-ID: <1992Sep10.033525.8850@athena.cs.uga.edu>
  6. Date: 10 Sep 92 03:35:25 GMT
  7. Sender: shen@athena.cs.uga.edu (Mingzuo Shen)
  8. Distribution: usa
  9. Organization: University of Georgia, Athens
  10. Lines: 68
  11.  
  12. Hi all,
  13.  
  14.     I am having a slight problem trying to run a simple
  15. program which calls strtok(), listed below. I wonder
  16. if the problems, described in the comment, is my own
  17. doing or local configuration, or generally known.
  18. Thanks for any information.
  19.  
  20. mingzuo
  21.  
  22.  
  23. /***********************************************************************
  24.   expected output:
  25.   DECstation 3100 (cc 1.31 and gcc 1.39)
  26.   Sun3 (cc)
  27.   HP 9000/700 (HP-UX 8.x)
  28.   IBM 3090 (AIX/370 1.2x)
  29. Find words, all of them. basis=120
  30. found word: Find
  31. found word: words
  32. found word: all
  33. found word: of
  34. found word: them
  35. found word: basis
  36. found word: 120
  37. Find
  38.  
  39.   problems:
  40.   xlc 1.1 (IBM RS/6000 AIX 3.1, xerxes)
  41.   xlc 1.2 (IBM RS/6000 AIX 3.2, hydarnes)
  42. Find words, all of them. basis=120
  43. Memory fault
  44.   cc is OK (on both xerxes and hydarnes)
  45.   cc -c ustrtok.c
  46.   xlc ustrtok.o
  47.   ./a.out OK
  48.  
  49.   gcc 1.39 (Sun4 SunOS 4.1.1)
  50.   cc -c ustrtok.c
  51.   gcc ustrtok.o
  52.   ./a.out OK
  53.  
  54. ***********************************************************************/
  55.  
  56. #include <stdio.h>
  57. #include <string.h>
  58.  
  59. int
  60. main()
  61. {
  62.   char *p;
  63.   char *buffer = {"Find words, all of them. basis=120"};
  64.   char *delims = {" .,="};
  65.  
  66.   fprintf(stdout,"%s\n", buffer);
  67.  
  68.   p = strtok(buffer, delims);
  69.  
  70.   while (p != NULL)
  71.     {
  72.       fprintf(stdout,"found word: %s\n", p);
  73.       p = strtok(NULL, delims);
  74.     }
  75.  
  76.   fprintf(stdout,"%s\n", buffer);
  77.  
  78.   return(0);
  79. }
  80.