16 lines
407 B
C++
16 lines
407 B
C++
#include <string>
|
|
#include <vector>
|
|
|
|
static std::vector<std::string> split(const std::string& s, char delimiter) {
|
|
std::vector<std::string> tokens;
|
|
std::string token;
|
|
std::stringstream ss(s); // 创建字符串流
|
|
|
|
// 使用 std::getline 从字符串流中读取以分隔符分隔的子字符串
|
|
while (std::getline(ss, token, delimiter)) {
|
|
tokens.push_back(token);
|
|
}
|
|
|
|
return tokens;
|
|
}
|
|
#pragma once |