zoukankan      html  css  js  c++  java
  • 关于std::vector<std::string>的操作

    知识点

    1 std::vector<std::string> 作为返回参数

    void GetConfigState(std::vector<std::string>&vtTemp)

    2 对于std::vector<std::string>取值操作

    std::vector<std::string>::iterator theIterator;

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

    cout<<theIterator->c_str()<<endl;//这样取值

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

    #include <iostream>
    #include <vector>
    using namespace std;
     void GetConfigState(std::vector<std::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());
        }
    }
    int main()
    {
        
        std::vector<std::string> vtTemp;
        std::vector<std::string>::iterator theIterator;
    
        GetConfigState(vtTemp);
        for( theIterator = vtTemp.begin(); theIterator != vtTemp.end(); theIterator++ )
            cout<<theIterator->c_str()<<endl;
         getchar();
        return 0;
    }

      

  • 相关阅读:
    数据库查询语言(DQL)
    MySQL的约束
    MySQL的数据类型
    SQL
    MySQL简介
    个人项目网址
    Nexus Repository Manager(CVE-2020-10199/10204)漏洞分析及回显利用方法的简单讨论
    Joomla 3.0.0
    Groovy 反序列化漏洞分析(CVE-2015-3253)
    PHP反序列化漏洞新攻击面(BlackHat 2018)
  • 原文地址:https://www.cnblogs.com/xzlq/p/3118641.html
Copyright © 2011-2022 走看看