can just split by space and store into an array. first thing that comes to mind is this
Code
int main()
{
char userInput[81];
char *functionOutput[80];
int i = 0;
printf("Enter a string to test the split function\n");
fgets(userInput, sizeof(userInput), stdin);
split(userInput, ".", functionOutput);
while(functionOutput[i] != '\0')
{
printf("%s\n", functionOutput[i]);
i++;
}
getchar();
return 0;
}
void split(char *input, char *dilimeter, char **output)
{
int i = 0;
output[0] = strtok(input, dilimeter);
while(output[i] != NULL)
{
i++;
output[i] = strtok(NULL, dilimeter);
}
output[i + 1] = '\0';
}
you dont necessarily need regex. see if your language has has string functions. python has a net set iirc.
could also do something like this.
Code
char *pch, *pch2;
pch = data;
pch2 = data;
while(*pch)
if(*pch == ' ')
memcopy(newdata, data, pch - pch2);
pch2 = pch;
or something like that
This post was edited by AbDuCt on Feb 28 2013 01:13am