回复 10楼 xzy199999
#include <stdio.h>#include <string.h>
char *convert(char *dest)
{
char *head=dest;
char *ss=dest;
static char a[10] = {0};
char *src = a;
while(*dest)
{
if(*dest!=':')
{
dest++;
}
else
{
head=dest;
dest--;
while((*dest != ':')&&( strcmp(dest , ss) != 0))
{
*src=*dest;
src++;
dest--;
}
dest=head;
dest++;
}
}
return a;
}
int main()
{
char *s="ab:cd";
printf("%s\n",convert(s));
return 0;
}
我运行了下就是我分析的那样,你试试吧