#include #include // split_into_something_like_argv char ** split(char *starting_string, size_t *length){ size_t spaces = 0; for(char *i = starting_string; *i; i++) if(*i == ' ') spaces++; char **return_value = malloc(sizeof(char*) * spaces); return_value[0] = starting_string; size_t word = 1; for(char *i = starting_string; *i; i++) if(*i == ' '){ while(*(i+1) == ' '){ *i = 0; i++; } return_value[word++] = i + 1; *i = 0; } *length = spaces; return return_value; } int main(int argc, char ** argv){ char phrase[] = "There is a giraffe looking in the window right now. The one on the East side of this room"; size_t length; char ** words = split(phrase, &length); printf("["); for(int i = 0; i < length; i++) printf("%s, ", words[i]); printf("\b\b]\n"); free(words); return 0; }