c语言中字符串分割的问题
#include<stdio.h>#include<stdlib.h>
#include<string.h>
char str[] = "clamscan c:\\Documents and Settings d:\\test e:\\a and b f:\\c and d";
int main(void)
{
int i=0,j=0;
char (*pStr)[128]=NULL;
char *s=str;
char *ss = NULL;
while(1)
{
pStr = (char(*)[128])realloc(pStr,(i+1)*(128));
memset(*(pStr+i),0,128);
ss = strchr(s,':');
if(i==0)
{
if(ss==NULL)
{
strcpy(*(pStr+i),s);
i++;
break;
}
else
{
memcpy(*(pStr+i),s,ss-s-2);
s = ss+1;
i++;
continue;
}
}
else
{
if(ss=NULL)
{
strcpy(*(pStr+i),s-2);
i++;
break;
}
else
{
memcpy(*(pStr+i),s-2,ss-s);
s = ss+1;
i++;
}
}
}
printf("After despare,the strings are:\n");
for(j=0;j<i;j++)
{
printf("%s\n",*(pStr+j));
}
free(pStr);
return 0;
}
各位大虾们帮忙看一下到底哪里出错了?小弟先谢谢各位大虾了.