// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
#include <iostream>
#include <vector>
#include <string>

using namespace std;

vector<string> split(char sep,string s)
{
    vector<string> res;
    string tmp = "";
    for(int i=0;i<s.size();i++)
    {
        if(s[i]==sep)
        {
            if(tmp.size()>0)
            {
                res.push_back(tmp);
                tmp = "";
            }
        }
        else
        {
            tmp = tmp + s[i];
        }
    }
    if(tmp.size()>0)
    {
        res.push_back(tmp);
    }
    return res;
}

int main()
{
    vector<string> res = split(' ',"a bb ccc   dddd");
    for(int i=0;i<res.size();i++)
    {
        cout << res[i] << endl;
    }
    return 0;
}
