#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>

typedef wchar_t CharType;
typedef std::basic_string<CharType> StringType;
typedef std::vector<StringType> ContainerType;
typedef std::basic_istringstream<CharType> IStringStreamType;

void SplitString(StringType const &str, CharType delim, ContainerType &collection)
{
    IStringStreamType ss(str);
    while (ss.good())
    {
        StringType token;
        std::getline(ss, token, delim);
        collection.push_back(token);
    }
}

int main()
{
    const CharType * const theString = L"select * from table1; select * from table2;";
    ContainerType col;
    SplitString(theString, L';', col);
    std::for_each(
        col.begin()
        , col.end()
        , [] (StringType const &s) { std::wcout << s << std::endl; }
    );
    return 0;
}
