I am trying to split a line into an array of words, but I am stuck on how to do this in C. My skills in C aren't very good, so I can't think of a way to "execute" my idea. Her is what I have so far:
int beginIndex = 0;
int endIndex = 0;
int maxWords = 10;
while (1) {
   while (!isspace(str)) {
      endIndex++;
   }
   char *tmp = (string from 'str' from beginIndex to endIndex)
   arr[wordCnt] = tmp;
   wordCnt++;
   beginIndex = endIndex;
   if (wordCnt = maxWords) {
       return;
   }
}
In my method I receive (char *str, char *arr[10]), and str is the line that I want to split when I encounter a space. arr is the array where I want to store the words. Is there any way to copy the 'chunk' of string that I want from 'str' into my tmp variable? This is the best way that I can think of right now, perhaps it's a terrible idea. If so, I would be happy to get some documentation or tips on a better method.
 
     
    