[c/c++]格式化字符串到字符串数组

int splitstr(  char *s,const  char *d,char **str ,int *num)
{
    char *p=NULL;
    int arrNum=0;
    if (s == NULL || strlen(s) == 0) return 0;
    if (d == NULL || strlen(d) == 0) return 0;
    p=strtok(s,d);
    while (p)
    {
        *str++=p;
        arrNum++;
        p=strtok(NULL,d);
    }
    *num=arrNum;
    return 1;
}

posted on 2012-11-18 18:23  狼爱上羊  阅读(483)  评论(0编辑  收藏  举报

导航