#include<fstream>
#include<iostream>
#include<string>
#include <vector>
using namespace std;
vector< string> split(string str, string pattern)
{
vector<string> ret;
if (pattern.empty()) return ret;
size_t start = 0, index = str.find_first_of(pattern, 0);
while (index != str.npos)
{
if (start != index)
ret.push_back(str.substr(start, index - start));
start = index + 1;
index = str.find_first_of(pattern, start);
}
if (!str.substr(start).empty())
ret.push_back(str.substr(start));
return ret;
}
int main()
{
string pattern = " ";
vector <string> result;
string name;
ifstream in("C:/Users/Administrator/Desktop/save_paper.txt");
while (!in.eof())
{
getline(in, name);
if (name.empty())
{
continue;
}
result = split(name, pattern);
cout << result[0] << endl;
}
}
如果文章或资源对您有帮助,欢迎打赏作者。一路走来,感谢有您!
txttool.com 说一段 esp56物联 查询128 IP查询