is there an easier way?
kline at thought.org
Mon Feb 18 23:03:59 UTC 2008
To my fellow C nerds,
It's been a great manny years since I wrote this appended
snippet. Now I can't remember why (of if ) I need all the
strcpy() calls. Is there a simpler, more logical way of
printing a bunch of string by snipping off the left-most?
In short,, can anyone 'splain why strtok needs all this?
Gary Kline kline at thought.org www.thought.org Public Service Unix
char *bp, buf, *tok, tstr;
static char *delim=" ", s1="abc def ghi jkl mno.";
bp = strcpy(buf, tstr);
strcpy(bp, s1); /* bp filled with writable mem works like this, too */
while ((tok = strtok(bp, delim)) != NULL)
bp = NULL;
printf("tok = [%s]\n", tok);
More information about the freebsd-questions