#include <stdio.h>
#include <string.h>
#include <malloc.h>
int main(void)
{
char * temp = "Front%20matter%20front.htm";
char *new=(char *)malloc(strlen(temp));
//用来存放处理后的字符串
int i=0;
int j=0;
char *s0=temp;
int li=0;
int lj=0;
while((unsigned)i<=strlen(temp))
{
if(*(temp + i) == '%')
{
memcpy(new+lj,temp+li,i-li);
*(new+j)=' ';
j++;
lj=j;
i+=3;
li=i;
continue;
}
if(*(temp + i) == '\0')
{
memcpy(new+lj,temp+li,i-li);
*(new+j)='\0';
break;
}
i++;
j++;
}
printf("new character = %s\n", new);
return 0;
}
是不是很拖沓,
不过我也就这水平了,
不知道改成这样效率会不会高点?