• 关于std::vector<std::string>的操作


    知识点

    1 std::vectorstd::string 作为返回参数

    void GetConfigState(std::vectorstd::string&vtTemp)

    2 对于std::vectorstd::string取值操作

    std::vectorstd::string::iterator theIterator;

    for( theIterator = vtTemp.begin(); theIterator != vtTemp.end(); theIterator++ )

    cout

    3 不能直接进行容器间赋值

    #include
    #include
    using namespace std;
    void GetConfigState(std::vectorstd::string&vtTemp)
    {
    unsigned int nLen = 0;
    unsigned int nValue = 0;
    std::string strType_Item;
    std::string strType_Items;
    std::string strTemp =“AT+CFUN=1;AT+CFUN=0”;
    int nPos = strTemp.find(“;”,0);
    int j = 0;
    while (nPos != -1)
    {
    vtTemp.push_back(strTemp.substr(0,nPos));
    nPos ++;
    strTemp = strTemp.substr(nPos,strTemp.length() - nPos);
    nPos = strTemp.find(“,”,0);

        j++;
    }
    if (strTemp.length() != 0)
    {
        vtTemp.push_back(strTemp.c_str());
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    }
    int main()
    {

    std::vector vtTemp;
    std::vector::iterator theIterator;
    
    GetConfigState(vtTemp);
    for( theIterator = vtTemp.begin(); theIterator != vtTemp.end(); theIterator++ )
        cout<c_str()<
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    }

  • 相关阅读:
    PyQt5快速开发与实战 3.4 信号与槽关联
    最新版两款不同版SEO超级外链工具PHP源码
    C Primer Plus(6) 中文版 第7章 C控制语句:分支和跳转 7.6 循环辅助:continue和break
    正则表达式
    LeetCode307 周赛(补记)
    【考研复试】计算机相关专业面试英语自我介绍范文(一)
    geoserver2.18(8):添加CSW(网络目录服务)扩展及前端开发调用
    [Java]异常
    redis_two
    c# 开发的wpf程序闪退,无法用try catch捕获异常
  • 原文地址:https://blog.csdn.net/baiyifei2016/article/details/126163315