当前位置:网站首页>Combining strings and numbers using ssstream
Combining strings and numbers using ssstream
2022-06-13 01:46:00 【No change of name】
0. Header file and namespace
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
using namespace std;1. Realization
Use opencv when , Easily read numbered pictures
int main(){
string path = "C:/imgs/";
stringstream stm;
string temppath;
vector<string>imgspath;
for (int i = 1; i < 10; i++)
{
stm << i;
stm >> temppath;
path = path + temppath + ".jpg";
cout << path << endl;
imgspath.push_back(path);
path = "C:/imgs/";
// stm Data can be written only after the data in is cleared
stm.clear();
}
return 0;
}2. Read more data
int main(){
// When you want to be in stringstream When storing more content in , Can be entered at one time
string s1 = "hello ";
string s2 = " world ";
int value1 = 1;
int value2 = 2;
stringstream ss;
ss << s1 << value1 << s2 << value2;
cout << ss.str() << endl;
return 0;
}3. Complete code
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
using namespace std;
int main(){
string path = "C:/imgs/";
stringstream stm;
string temppath;
vector<string>imgspath;
for (int i = 1; i < 10; i++)
{
stm << i;
stm >> temppath;
path = path + temppath + ".jpg";
cout << path << endl;
imgspath.push_back(path);
path = "C:/imgs/";
// stm Data can be written only after the data in is cleared
stm.clear();
}
// When you want to be in stringstream When storing more content in , Can be entered at one time
string s1 = "hello ";
string s2 = " world ";
int value1 = 1;
int value2 = 2;
stringstream ss;
ss << s1 << value1 << s2 << value2;
cout << ss.str() << endl;
return 0;
}4. Results show

边栏推荐
- The first cell of devaxpress CXGRID after inserting a row is in focus editing status
- Crypto JS reports uglifyjs error
- Temporary objects and compilation optimization
- Stone from another mountain: Web3 investment territory of a16z
- Devaxpress Chinese description --tcximagelist (enhanced image list control)
- 五、库存查询功能的完善
- JSON and protobuf Any interchange
- 如何利用您的自有数据来实现营销目标?
- Restrict cell input type and display format in CXGRID control
- Audiences with similar interests
猜你喜欢

Using OpenCV in go

移动IPv6光猫登录的一般ip地址账号与密码,移动光猫变桥接模式

Introduction to Google unit testing tools GTEST and gmoke

【MathType】利用MathType输出LaTex样式的公式

Record the VMware installation process of VMware Tools and some problems encountered

路径字段是什么? ——竞价广告

Devaxpress Chinese description --tcxpropertiesstore (property store recovery control)

Workspace for ROS

leetcode743. 网络延迟时间(中等, dijkstra)

Use koa to mock data and set cross domain issues
随机推荐
Matplotlib drawing Chinese garbled code
Magics 23.0如何激活和使用视图工具页的切片预览功能
六、出库管理功能的实现
[soft test] software designer knowledge points sorting (to be updated)
Detailed understanding of white noise
Delphi7 compressed pictures (BMP, JPG, PNG)
#pragma comment(lib,“urlmon.lib“)
PyFlink实现自定义SourceFunction
Unity jsonutility failed to serialize list
Copy (copy) constructors and assignment overloaded operators=
[WSL2]限制WSL2可访问的硬件资源(CPU/内存)
Detailed explanation of audience characteristics
Pyflink implements custom sourcefunction
Spit bubbles (stack)
pringboot之restfull接口规范注解(二)
[MathType] use MathType to output latex style formula
Traversal of binary tree - first order traversal, middle order traversal, and second order traversal
Unity JsonUtility 无法序列化List
Devaxpress Chinese description --tdximageslider (picture rotation control)
Shell command notes