*EDIT-I know strtok doesn't actually 'return' a segfault-I realize after submitting topic that is poor wording.
Hello,
I am having a problem with the C function strtok, as follows:
void function_name (char * cmd) /* Gathered from another function using readline. Assume 'ls -l' in this example */
{
char *pch = NULL;
/* Other variable declarations */
printf ("%s\n", cmd); /* correctly prints 'ls -l' */
printf ("Before call to strtok\n");
pch = strtok (cmd, " ");
printf ("After call to strtok\n"); /* This line never prints due to segfault */
}
I am attempting to parse the 'ls -l' to pass to function execlp()
or similar functions-I am required by constraints of assignment to get data via readline.
Thank you for any help can provide.