home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!haven.umd.edu!darwin.sura.net!spool.mu.edu!sol.ctr.columbia.edu!emory!athena.cs.uga.edu!shen
- From: shen@athena.cs.uga.edu (Mingzuo Shen)
- Newsgroups: comp.unix.aix
- Subject: xlc does not like strtok()?
- Message-ID: <1992Sep10.033525.8850@athena.cs.uga.edu>
- Date: 10 Sep 92 03:35:25 GMT
- Sender: shen@athena.cs.uga.edu (Mingzuo Shen)
- Distribution: usa
- Organization: University of Georgia, Athens
- Lines: 68
-
- Hi all,
-
- 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.
-
- mingzuo
-
-
- /***********************************************************************
- 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);
- }
-