#include <iostream>
#include <string>
#include <vector>
using namespace std;
using std::string;
using std::vector;
int split(vector<string>& list,const string& src)
{
const char *p=src.c_str();
char *p1,*p2;
p1 = p2 = const_cast<char *>(p);
while((*p2)!='\0')
{
if((*p2)==',')
{
list.push_back(string(p1,p2));
p1=p2+1;
}
++p2;
}
if (list.size()>0)
{
list.push_back(string(p1,p2));
}
return list.size();
}
int main(void)
{
string a("ab");
vector<string> list;
split(list,a);
cout<<list.size()<<endl;
for (std::vector<string>::iterator iter = list.begin(); iter != list.end(); ++iter)
{
std::cout << *iter << std::endl;
}
return 0;
}