zoukankan      html  css  js  c++  java
  • 字符串截取

    int main()
    {
    #if 0
    // 字符串截取1
    string strSrc = "name:orange score:96 id:03c648578a6e79bdeaf2cb8ee2651424 e-mail:xxxx@xx.com ";
    string::size_type nPos0 = strSrc.find("id:", 0);
    if(nPos0 == string::npos) return -1;
    nPos0 += 3;
    string::size_type nPos1 = strSrc.find(" ", nPos0);
    if(nPos1 == string::npos) return -1;
    string strId = strSrc.substr(nPos0, nPos1 - nPos0 + 1);
    cout << strId << endl;

    // 字符串截取2
    string str="第一 第二 第三 第四 第五";
    string strTemp="";
    vector<string> strVec;
    int iPos0 = 0;
    while (string::npos != str.find(" ", 0))
    {
    iPos0 = str.find(" ", 0);
    strVec.push_back(str.substr(0,iPos0));
    str = str.substr(iPos0+1,str.length()-iPos0);
    }
    // 最后一个字符串


    system("pause");
    return 0;
    #endif

    /*
    //截取字符串,直到遇到换行
    string::size_type nPos0 = DGI.find("DGI0101|", 0);
    // if(nPos0 == string::npos) return -1;
    nPos0 += 12;
    string::size_type nPos1 = DGI.find(" ", nPos0);
    // if(nPos1 == string::npos) return -1;
    string strId = DGI.substr(nPos0, nPos1 - nPos0 + 1);
    cout << strId << endl; */

    CString m_ATR="3DDEW553636DD";
    char atr[200]={0};
    memcpy(atr,m_ATR.GetBuffer(m_ATR.GetLength()),m_ATR.GetLength());
    cout<<atr<<endl;
    return 0;
    }

  • 相关阅读:
    CentOS 7 调整home大小
    跨站请求拦截
    SVN操作
    openoffice安装
    MySQL报错ERROR 1436 (HY000): Thread stack overrun:
    jolokia配置Java监控
    elasticksearch分词,导致kibana的url出现问题
    C语言scanf跳出循环的问题
    Jenkins远程代码执行漏洞
    ActiveMQ FileServer漏洞(详细)
  • 原文地址:https://www.cnblogs.com/Pond-ZZC/p/10823522.html
Copyright © 2011-2022 走看看