• 关于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

    }

  • 相关阅读:
    物联网AI MicroPython传感器学习 之 WS2812 RGB点阵灯环
    8.RabbitMQ系列之RPC
    一个简单的查询学生信息的接口测试
    Vue.js结合ASP.NET Core构建用户登录与权限验证系统
    概率神经网络的主要思想,神经网络随机数预测
    C# 基类中的虚函数调用基类的虚函数执行的是派生类实现的对应函数吗
    19 | spark 统计 每列的数据非缺失值
    SyntaxError: invalid character in identifier
    中科磐云—D模块解析以及评分标准
    JVM内存调优-实践测试
  • 原文地址:https://blog.csdn.net/baiyifei2016/article/details/126163315