Splitting string into words

Here is an example: boy girl good word aa why stuff

I would like to basically split this string into words and store them in an array. Here is the array am talking about:

1
2
3
4
5
Array= calloc(15, sizeof(char*));
    //now allocate memory for each individual members in the array
    for(i=0; i<15; i++){
    Array[i]=calloc(200, sizeof(char));
    }


Now the words are separated by space but its not always one, sometimes is 1,2, 3 or more. Now how do I even begin to dissect this string into separate into words?

Also I am working in C.
Last edited on
#include <cstring>

strtok() to return strings between the delimiter or look at string exploding functions to automatically slice into an array.

You might want to run a procedure to remove all excess spaces.
Last edited on
Topic archived. No new replies allowed.