The input is a standard string input. Like this.
"Anand,Ramesh,Suresh#Anand,Ramesh,Suresh,Suresh,Anand"
I want to get get all the Names before the # and store it in an array. And use the names after the # to do some operation.
How do I copy the first three names before # to an array. So far I've figured out how to copy string seperated by comma. I couldn't find a solution to stop after a particular element is found.How do I stop when I encounter a #. Here is my code so far:
void findCombination(string input)
{
stringstream ss(input);
string buffer;
vector<string>names;
int i=0;
while(getline(ss,buffer,','))
{
names.push_back(buffer);
}
for(int i=0;i<names.size();i++)
cout << names[i] <<endl;
//return NULL;
}