func:可以基本显示目标结果。
This commit is contained in:
18
public_def.cpp
Normal file
18
public_def.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
#include "public_def.h"
|
||||
|
||||
std::vector<std::string> splitString(const std::string& input, const std::string& delimiter) {
|
||||
std::vector<std::string> tokens;
|
||||
size_t pos = 0;
|
||||
std::string backup = input;
|
||||
std::string token;
|
||||
|
||||
while ((pos = backup.find(delimiter)) != std::string::npos) {
|
||||
token = backup.substr(0, pos);
|
||||
tokens.push_back(token);
|
||||
backup.erase(0, pos + delimiter.length());
|
||||
}
|
||||
// Push the remaining part after the last delimiter
|
||||
tokens.push_back(backup);
|
||||
|
||||
return tokens;
|
||||
}
|
||||
Reference in New Issue
Block a user