#include <iostream> #include <sstream> #include <vector> using namespace std; vector<string> split (const string &s, char delim) { vector<string> result; stringstream ss (s); string item; while (getline (ss, item, delim)) { result.push_back (item); } return result; } int main() { string str = "adsf+qwer+poui+fdgh"; vector<string> v = split (str, '+'); for (auto i : v) cout << i << endl; return 0; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter