#include <string>
#include <vector>
vector<string> split(string s, string delimiter)
{
using namespace std;
size_t pos = 0;
string token;
vector<string> splitStrings(0);
while ((pos = s.find(delimiter)) != string::npos) {
token = s.substr(0, pos);
splitStrings.push_back(token);
s.erase(0, pos + delimiter.length());
}
if (s.size() > 0)
{
splitStrings.push_back(s);
}
return splitStrings;
}
반응형
'프로그래밍 > C++' 카테고리의 다른 글
C++ 벡터에서 Index 찾기 (1) | 2024.01.06 |
---|