Advertisement
thewitchking

Untitled

Jun 22nd, 2025
393
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.51 KB | None | 0 0
  1. std::vector<std::string> splitString(const std::string& input) {
  2.     std::vector<std::string> result;
  3.     std::stringstream ss(input);
  4.     std::string token;
  5.  
  6.     while (std::getline(ss, token, ' ')) { // split by space
  7.         std::stringstream commaStream(token);
  8.         std::string subToken;
  9.         while (std::getline(commaStream, subToken, ',')) { // split by comma
  10.             if (!subToken.empty()) {
  11.                 result.push_back(subToken);
  12.             }
  13.         }
  14.     }
  15.  
  16.     return result;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement