Name: Anonymous 2007-08-19 22:57 ID:my26XLFz
For web development? You faggots bash PHP all the time. Is it because it's popular it's 'cool' not to like it?
int main() {
char buffer[] = "jave dones";
char **p;
size_t n;
size_t tokens = 2;
for(n = 0; n < sizeof buffer - 1; n++)
if(buffer[n] == ' ') tokens++;
p = malloc(tokens * sizeof *p);
if(p == NULL) {
perror("malloc");
return -1;
}
if(tokens == 2) {
p[0] = buffer;
p[1] = NULL;
} else {
*p = strtok(buffer, " ");
for(n = 1; n < tokens; p[n] = strtok(NULL, " "))
;
}
return 0;
}