当前位置:网站首页>关于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;
}
边栏推荐
猜你喜欢
随机推荐
Hands-on Deep Learning_NiN
win10 uwp use WinDbg to debug
[larave]关于laravel使用form submit()不能获取值问题
PowerCLi batch configuration of NTP
js data type, throttling/anti-shake, click event delegation optimization, transition animation
开发deepstram的自定义插件,使用gst-dseaxmple插件进行扩充,实现deepstream图像输出前的预处理,实现图像自定义绘制图(精四)
经验分享|盘点企业进行知识管理时的困惑类型
SPSS-unary regression practice
buu web
ini怎么使用? C#教程
PRIMAL: Pathfinding via Reinforcement and Imitation Multi-Agent Learning Code Analysis
In which industries is the PMP certificate useful?
[Linear Algebra 02] 2 interpretations of AX=b and 5 perspectives of matrix multiplication
【uiautomation】微信好友列表获取(存储到txt中)
Some problems with passing parameters of meta and params in routing (can be passed but not passed, empty, collocation, click to pass multiple parameters to report an error)
The upgrade and transformation plan of the fortress machine for medium and large commercial banks!Must see!
OD-Model [6]: YOLOv2
Altium Designer 19.1.18 - draw polygons copper hollow out, for the cursor just capture solutions
Spss-一元回归实操
基于声卡实现的音频存储示波器,可作为电磁学实验的测量仪表