Implementing Split function in C
问题 I'm trying to write a C function that is similar to split in Java. When I do what I do at main, instead of add function, it works perfectly. But I couldn't understand why it does not work with add function. #include <stdio.h> #include <string.h> char *words[50] = { NULL }; void add(const char *word) { static int i = 0; words[i] = word; i++; } int main( void ) { char string[65]; char *tokenPtr; fgets(string, 65, stdin); tokenPtr = strtok( string, " " ); add(tokenPtr); int i = 0; while (