Good News, you can.
Here is an example to Illustrate how it is done.
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
/****************************************************************************
* *
* Function: Split (Perl's "split" function for C) *
* *
* Purpose: Given a string and delimiter of any length returns an array of *
* strings which are tokens that are separated by the delimiter in the *
* original string. The original string is not touched. This emulates the *
* functionality of Perl's "split" function (minus the use of regular *
* expressions). *
* *
****************************************************************************/
char** Split(char *Input, char *Delim, char ***List, int *TokenCount)
{
int Found, Length, DelimLen = strlen(Delim);
char *Remain, *Position;
if ((List == NULL) || (Input == NULL) || (Delim == NULL))
{
*TokenCount=-1;
return NULL;
}
//first pass -- count number of delimiters
for (Found = 1, Remain = Input;
(Position = strstr(Remain, Delim));
Found++) Remain = Position + DelimLen;
//create array based on number of delimiters
*List = (char **)malloc((Found+1) * sizeof(char *));
//second pass -- populate array
for (Found = 0,Remain = Input;
(Position = strstr(Remain, Delim),1);
Remain = Position + DelimLen)
{
Length = Position? Position - Remain : strlen(Remain);
(*List)[Found] = (char *)malloc(sizeof(char)*(Length+1));
strncpy((*List)[Found], Remain, Length);
(*List)[Found++][Length] = 0;
if(!Position){(*List)[Found] = Position; break;}
}
*TokenCount = Found;
return *List;
} /* Split() */
/* Destroys the array of strings structure returned by Split() */
void FreeSplitList(char **List)
{
int Count = 0;
while(List[Count]) free(List[Count++]);
free(List);
} /* FreeSplitList() */
/****************************************************************************
* *
* Function: main *
* *
* Purpose : Main entry point. *
* *
* History : Date Reason *
* 00/00/00 Created *
* *
****************************************************************************/
int main(int argc, char *argv[])
{
char *str = "The Quick Brown Fox Jumpped Over The Lazy Dogs";
char **strList;
int iCount;
Split(str," ",&strList,&iCount);
for(int i=0; i<iCount;i++)
{
printf("%s \n", strList[i]);
}
FreeSplitList(strList);
return 0;
}