home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.aix
- Path: sparky!uunet!newsgate.watson.ibm.com!yktnews!admin!yktnews!prener
- From: prener@watson.ibm.com (Dan Prener)
- Subject: Re: xlc does not like strtok()?
- Sender: news@watson.ibm.com (NNTP News Poster)
- Message-ID: <PRENER.92Sep10030527@prener.watson.ibm.com>
- In-Reply-To: shen@athena.cs.uga.edu's message of 10 Sep 92 03:35:25 GMT
- Date: Thu, 10 Sep 1992 08:05:27 GMT
- Distribution: usa
- Disclaimer: This posting represents the poster's views, not necessarily those of IBM
- References: <1992Sep10.033525.8850@athena.cs.uga.edu>
- Nntp-Posting-Host: prener.watson.ibm.com
- Organization: IBM T.J. Watson Research Center, Hawthorne, New York
- Lines: 75
-
- In article <1992Sep10.033525.8850@athena.cs.uga.edu> shen@athena.cs.uga.edu (Mingzuo Shen) writes:
-
- > I am having a slight problem trying to run a simple
- >program which calls strtok(), listed below. I wonder
- >if the problems, described in the comment, is my own
- >doing or local configuration, or generally known.
- >Thanks for any information.
-
-
- >/***********************************************************************
- > expected output:
- > DECstation 3100 (cc 1.31 and gcc 1.39)
- > Sun3 (cc)
- > HP 9000/700 (HP-UX 8.x)
- > IBM 3090 (AIX/370 1.2x)
- >Find words, all of them. basis=120
- >found word: Find
- >found word: words
- >found word: all
- >found word: of
- >found word: them
- >found word: basis
- >found word: 120
- >Find
-
- > problems:
- > xlc 1.1 (IBM RS/6000 AIX 3.1, xerxes)
- > xlc 1.2 (IBM RS/6000 AIX 3.2, hydarnes)
- >Find words, all of them. basis=120
- >Memory fault
- > cc is OK (on both xerxes and hydarnes)
- > cc -c ustrtok.c
- > xlc ustrtok.o
- > ./a.out OK
-
- > gcc 1.39 (Sun4 SunOS 4.1.1)
- > cc -c ustrtok.c
- > gcc ustrtok.o
- > ./a.out OK
-
- >***********************************************************************/
-
- >#include <stdio.h>
- >#include <string.h>
-
- >int
- >main()
- >{
- > char *p;
- > char *buffer = {"Find words, all of them. basis=120"};
- > char *delims = {" .,="};
-
- > fprintf(stdout,"%s\n", buffer);
-
- > p = strtok(buffer, delims);
-
- > while (p != NULL)
- > {
- > fprintf(stdout,"found word: %s\n", p);
- > p = strtok(NULL, delims);
- > }
-
- > fprintf(stdout,"%s\n", buffer);
-
- > return(0);
- >}
-
- xlc, as opposed to cc, defaults to keeping string literals in read-only
- storage. If you want to use xlc, add the option
-
- -qnoro
-
- With this, your program works properly when compiled with xlc.
- --
- Dan Prener (prener@watson.ibm.com)
-