Okay, point made. But I still have a few questions
Code:
#include <stdio.h>
#include <string.h>
int main ( ) {
char test_msg[]="This is a test message";
char *p;
char *delim = " ";
char *words[20];
int i = 0, j;
p = strtok(test_msg,delim);
while ( p ) {
words[i] = p;
p = strtok(NULL,delim);
i++;
}
printf ( "%d\n", i );
for ( j = 0 ; j < i ; j++ ){
printf("'%s'\n", words[j]);
}
}
p = strtok(NULL,delim);
What does this do and why? I know that it assigns a token to the char pointer p, and that spaces don't count as tokens, but what is NULL there for?