在C语言中如何实现对编码后的URL进行解码
关注:137 答案:2 信息版本:手机版
解决时间 2019-01-11 02:36
蓝琪梦莎
2019-01-10 13:44
在C语言中如何实现对编码后的URL进行解码
最佳答案
雾月
2019-01-10 14:42
字符串与数字量的转换,可以按照标准的编码(如Unicode,utf8等等)进行编码解码。URL编码就有编码规则,解码时就按既定的编码规则进行就可以了。
全部回答
1楼风格不统一
2019-01-10 16:18
turbo c 2.0编译通过
#include
#include
#include
#define length 100
void encode(char *strsource);
void decode(char *strcode);
void main()
{
char code[length]="bill gates";
encode(code);
printf("\nencoded string is:%s\n",code);
decode(code);
printf("\ndecoded string is:%s\n",code);
getch();
}
void encode(char *strsource){
char *p=strsource,tmp[length]={'\0'},buffer[3];
while(*p){
itoa(*p++,buffer,10);
strcat(tmp,"%");
strcat(tmp,buffer);
}
strcpy(strsource,tmp);
}
void decode(char *strcode){
int i=0;
char *p,*s=strcode,tmp[length]={'\0'};
char *csplit="%";
p=strtok(s,csplit);
while(p)
{
tmp[i++] = atoi(p);
p=strtok(null,csplit);
}
strcpy(strcode,tmp);
}
我要举报
如以上问答内容为色情/暴力/低俗/不良/侵权等信息,可以点下面链接进行举报,我们会做出相应处理,感谢你的支持!
大家都在看
推荐资讯