CGI做中文处理时的问题!

让人想犯罪 __ 提交于 2020-01-20 03:59:50
#include   <stdio.h>  
  #include   <stdlib.h>  
   
  int   main(void)  
  {  
    unsigned   int   i=0,max=30;  
    char*   dest;  
    dest=(char*)malloc(max);  
    if(!dest)exit   (1);  
    printf("input   your   code   string:   ");  
    while((dest[i]=getchar())=='%')  
    {  
  if((dest[++i]   =getchar())   >=   'A')  
  dest[i]   =   ((dest[i]   &   0xdf)   -   'A')   +   10;  
  else  
  dest[i]   =   dest[i]   -   '0';  
  if((dest[++i]   =getchar())   >=   'A')  
  dest[i]   =   ((dest[i]   &   0xdf)   -   'A')   +   10;  
  else  
  dest[i]   =   dest[i]   -   '0';  
  dest[i/3]=dest[i]+dest[i-1]*16;  
  i++;  
  if(i==max)  
  {  
  max+=max;  
  dest=(char*)realloc(dest,max);  
  if(!dest)   exit(1);  
  }  
    }  
    dest[i/3]='\0';  
    printf("this   decode   string   is:%s\n",dest);  
    free(dest);  
    return   0;  
  }  
   
   
  献丑了:)  
   
  你输入一段%**%**   试试
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!