现在的位置: 首页 > 综合 > 正文

string 用法小结

2013年08月13日 ⁄ 综合 ⁄ 共 319字 ⁄ 字号 评论关闭

  1 long  to  char *

        char basetime[32];
long mBaseTime;
mBaseTime = (long)time(NULL);
memset(basetime,0,sizeof(basetime));
ltoa(mBaseTime,basetime,10);

        basetime:“1345636789”

2 char * to  string

      string strtime;
      strtime= basetime;

3 分割字符

   
strtime = strtime.substr(5,5);

        strtime:“36789”

4 char* to long

     
msgid = atol(strtime.c_str());

【上篇】
【下篇】

抱歉!评论已关闭.