split string c++

    0

    0

    Mansimar Anand

    Split string in c++

    #include <bits/stdc++.h>
    using namespace std;
    vector<string> split(const string& s, const char& sep) {
    	string token;
    	stringstream X(s);
    	vector<string> tokens;
    	while (getline(X, token, sep)) {
    		tokens.push_back(token);
    	}
    	return tokens;
    }
    int32_t main()
    {
    	char sep = ',';
    	string s = "a,b,c";
      vector<string> arr = split(s, sep);
      	
    	return 0;
    }
    
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    Legal
    • Security
    • Privacy Policy
    • Code Privacy
    • Terms of Service
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.