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

  1. Newsgroups: comp.unix.aix
  2. Path: sparky!uunet!newsgate.watson.ibm.com!yktnews!admin!yktnews!prener
  3. From: prener@watson.ibm.com (Dan Prener)
  4. Subject: Re: xlc does not like strtok()?
  5. Sender: news@watson.ibm.com (NNTP News Poster)
  6. Message-ID: <PRENER.92Sep10030527@prener.watson.ibm.com>
  7. In-Reply-To: shen@athena.cs.uga.edu's message of 10 Sep 92 03:35:25 GMT
  8. Date: Thu, 10 Sep 1992 08:05:27 GMT
  9. Distribution: usa
  10. Disclaimer: This posting represents the poster's views, not necessarily those of IBM
  11. References: <1992Sep10.033525.8850@athena.cs.uga.edu>
  12. Nntp-Posting-Host: prener.watson.ibm.com
  13. Organization: IBM T.J. Watson Research Center, Hawthorne, New York
  14. Lines: 75
  15.  
  16. In article <1992Sep10.033525.8850@athena.cs.uga.edu> shen@athena.cs.uga.edu (Mingzuo Shen) writes:
  17.  
  18. >    I am having a slight problem trying to run a simple
  19. >program which calls strtok(), listed below. I wonder
  20. >if the problems, described in the comment, is my own
  21. >doing or local configuration, or generally known.
  22. >Thanks for any information.
  23.  
  24.  
  25. >/***********************************************************************
  26. >  expected output:
  27. >  DECstation 3100 (cc 1.31 and gcc 1.39)
  28. >  Sun3 (cc)
  29. >  HP 9000/700 (HP-UX 8.x)
  30. >  IBM 3090 (AIX/370 1.2x)
  31. >Find words, all of them. basis=120
  32. >found word: Find
  33. >found word: words
  34. >found word: all
  35. >found word: of
  36. >found word: them
  37. >found word: basis
  38. >found word: 120
  39. >Find
  40.  
  41. >  problems:
  42. >  xlc 1.1 (IBM RS/6000 AIX 3.1, xerxes)
  43. >  xlc 1.2 (IBM RS/6000 AIX 3.2, hydarnes)
  44. >Find words, all of them. basis=120
  45. >Memory fault
  46. >  cc is OK (on both xerxes and hydarnes)
  47. >  cc -c ustrtok.c
  48. >  xlc ustrtok.o
  49. >  ./a.out OK
  50.  
  51. >  gcc 1.39 (Sun4 SunOS 4.1.1)
  52. >  cc -c ustrtok.c
  53. >  gcc ustrtok.o
  54. >  ./a.out OK
  55.  
  56. >***********************************************************************/
  57.  
  58. >#include <stdio.h>
  59. >#include <string.h>
  60.  
  61. >int
  62. >main()
  63. >{
  64. >  char *p;
  65. >  char *buffer = {"Find words, all of them. basis=120"};
  66. >  char *delims = {" .,="};
  67.  
  68. >  fprintf(stdout,"%s\n", buffer);
  69.  
  70. >  p = strtok(buffer, delims);
  71.  
  72. >  while (p != NULL)
  73. >    {
  74. >      fprintf(stdout,"found word: %s\n", p);
  75. >      p = strtok(NULL, delims);
  76. >    }
  77.  
  78. >  fprintf(stdout,"%s\n", buffer);
  79.  
  80. >  return(0);
  81. >}
  82.  
  83. xlc, as opposed to cc, defaults to keeping string literals in read-only
  84. storage.  If you want to use xlc, add the option
  85.  
  86.     -qnoro
  87.  
  88. With this, your program works properly when compiled with xlc.
  89. --
  90.                                    Dan Prener (prener@watson.ibm.com)
  91.