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;
    }

  • 相关阅读:
    014_Python3 循环语句
    013_Python3 条件控制
    012_Python3 斐波纳契数列 + end 关键字
    011_Python3 集合
    010_Python3 字典
    009_Python3 元组
    008_Python3 列表
    006_Python3 数字(Number)
    005_Python3 运算符
    bzoj3160
  • 原文地址:https://www.cnblogs.com/Pond-ZZC/p/10823522.html
Copyright © 2011-2022 走看看