当前位置:网站首页>关于std::vector<std::string>的操作
关于std::vector<std::string>的操作
2022-08-04 21:40:00 【android framework】
知识点
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<c_str()<<endl;//这样取值
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());
}
}
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;
}
边栏推荐
- Named routes, the role of name in components
- milvus配置相关
- docker 搭建mysql 主从复制
- Rocketchip RISC-V Debug调试硬件相关(四)hartIsInReset
- SPSS-System Clustering Hand Calculation Practice
- LayaBox---TypeScript---Problems encountered at first contact
- AI/ML无线通信
- LayaBox---TypeScript---structure
- 如何一键重装win7系统?重装win7系统详细教程
- laravel whereDoesntHave
猜你喜欢
随机推荐
立即升级!WPS Office 出现 0day 高危安全漏洞:可完全接管系统,官方推出紧急更新
milvus配置相关
LayaBox---TypeScript---举例
Unknown point cloud structure file conversion requirements
七夕,当爱神丘比特遇上牛郎和织女
ES6高级-async的用法
如何将二叉搜索树转化为一个有序的双向链表(原树上修改)
未知点云结构文件转换需求
MySQL查询为啥慢了?
C语言知识大全(一)——C语言概述,数据类型
UDP通信
[2022 Nioke Duo School 5 A Question Don't Starve] DP
LeetCode 199: 二叉树的右视图
可视化工作流引擎开发OA系统,让企业少花冤枉钱
SPSS-unary regression practice
stm32mp157系统移植 | 移植ST官方5.10内核到小熊派开发板
ES6高级-Promise的用法
JWT actively checks whether the Token has expired
【线性代数02】AX=b的2种解释和矩阵乘法的5种视角
Qiangwang Cup 2022 - WEB








