首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Symbian >

提取解决方案

2012-12-20 
提取大家好,怎么在Symbian中把{\key_duration\:3600,\newversion\:true,\ss_key\:\de36d72ec107e9d

提取
大家好,怎么在Symbian中把{"key_duration":3600,"newversion":true,"ss_key":"de36d72ec107e9d12833b7b04541f0d8","ss_ip":"223.4.10.125","ss_port":30002,"url":"http://223.4.10.125/welcome/download?soft=android&from=client&version=130"}里面的ss_key,ss_ip,ss_port中这三个值取出来
[解决办法]
没人吗?
[解决办法]



#include <stdio.h>
#include <stdlib.h>
#include <string.h>

const char* token[3]=
{
        "ss_key":"",
        "ss_ip":"",
        "ss_port":"
};

 char endMark[3]={'"','"',','};

#define MAX_VALUE_SIZE 50

int parse( char *input,char output[][MAX_VALUE_SIZE])      
{
        char *curIndex=input;
        int inputLen=strlen(input);

        for(int i=0;i<3;++i)
        {
                curIndex=strstr(curIndex,token[i]);

                if(curIndex==NULL)
                {
                        return -1;
                }

                curIndex+=strlen(token[i]);
                 char *end=strchr(curIndex,endMark[i]);

                if(end==NULL)
                {
                        return -1;
                }

                strncpy(output[i],curIndex,end-curIndex);
                output[i][end-curIndex]='\0';
                curIndex=end+1;
        }

        return 0;
}


int _tmain(int argc, _TCHAR* argv[])
{
  char *input="{"key_duration":3600,"newversion":true,"ss_key":"993b4b3fb795017c923004f12aa64244","ss_ip":"223.4.10.125","ss_port":30002,"url":"http://223.4.10.125/welcome/download?soft=android&from=client&version=130"}";

        char output[3][MAX_VALUE_SIZE];


        if(parse(input,output)==0)
        {
               


                
char *a = output[0];
char *b = output[1];
char *c = output[2];

               
        }

return 0;
}

这段代码怎么转换为Symbian程序,或者怎么加入到Symbian程序中?
[解决办法]
该回复于2011-11-14 09:46:44被版主删除

热点排行