当前位置:网站首页>关于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;
}
边栏推荐
猜你喜欢
随机推荐
SPSS-unary regression practice
buu web
七夕特制:《牛郎会织女》
LocalDate时间日期包的用法
硬件开发定制全流程解析
NFT宝典:你需要知道NFT的术语和定义
js data type, throttling/anti-shake, click event delegation optimization, transition animation
Why is MySQL query slow?
【QT】回调函数的实现
多个平台显示IP属地,必须大力推行互联网实名制
传奇服务器需要什么配置?传奇服务器租用价格表
数电快速入门(五)(编码器的介绍以及通用编码器74LS148和74LS147的介绍)
【线性代数03】消元法展示以及AX=b的4种解情况
如何为Web3.0世界启动完美的DAO
Is the International Project Manager PMP certificate worth taking?
dotnet compress Stream or file using lz4net
Analysis and treatment of Ramnit infectious virus
实战:10 种实现延迟任务的方法,附代码!
2022强网杯web(部分)
AXI interface application of Zynq Fpga image processing - the use of axi_lite interface