I'm sorry...



...to abuse the list like this (this will be the only time, I promise), 
but can any of you GCC/C hackers out there tell me why Gcc (2.7.2.3 on 
Linux x86) segfaults on execution of this program:

#include <stdio.h>
#include <string.h>

void main() {
    printf ("%s\n", strtok ("hey you", " "));
}

This is a correct usage of strtok, from what I have read.  I am trying to 
use this function in a project, but it segfaults every time.  It is 
standard ANSI C.  And, even weirder, I have gotten it to work on SunOS 
and IRIX systems using the cc that comes with the computer.  Is Gcc's 
implementation of strtok busted? (I highly dout it...but what am I doing 
wrong?)

shane



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]