/*Split a string.*/
void split_str(char *result[],char *haystack)
{
char *needle=" ";
char *buf=NULL;
char *re=NULL;
int i;
i=0;
buf=strstr(haystack,needle);
result[2]=NULL;
do
{
re=(char*)malloc(strlen(haystack)-strlen(buf));
memcpy(re,haystack,(strlen(haystack)-strlen(buf)));
haystack = buf + strlen(needle);
re[strlen(re)-1]='\0';
/* Get next token: */
result[i++]=re;
free(re);
buf = strstr( haystack, needle);
if(buf==NULL)
{
re=(char*)malloc(strlen(haystack));
memcpy(re,haystack,strlen(haystack));
re[strlen(re)-1]='\0';
result[i]=re;
free(re);
}
}while(buf!=NULL);
return;
}