#include <iostream>
#include <windows.h>
#include <vector>
#include <opencv2/opencv.hpp> //头文件
#include <sstream>
#include <fstream>
using namespace cv; //包含cv命名空间
using namespace std;
int main()
{
ifstream is;
is.open("1.txt", ifstream::in);
if (!is.good())
{
return -1;
}
string line;
while (getline(is,line))//逐行的读入数据
{
istringstream lines(line);//流操作
string temp;//保存临时数据
//int temp
while (getline(lines,temp,','))//以此读取每行以','分割的字符
{
//cout << temp << '\t';
//这里可以将其进一步转换为int类型的
istringstream Tran(temp);
int x;
Tran >> x;
cout << x << '\t';
}
cout << endl;
}
return 0;
}
以任意字符分割字符串
最新推荐文章于 2022-01-07 00:09:53 发布