Possible Duplicate:
strtok giving Segmentation Fault
Why do i get segfault using this code ?
void test(char *data)
{
char *pch;
pch = strtok(data, " ,.-"); // segfault
while (pch != NULL)
{
printf("%s\n", pch);
pch = strtok(NULL, " ,.-");
}
return NULL;
}
char *data = "- This, a sample string.";
test(data);