Please see efnx's modified version in comments, it is way more efficient than the original. (it does not use temporary vector, and copy it to store - instead it modifies the store vector straight away - which is way more efficient && elegant)
As I have somewhere sometimes stated, I have been writing some php as a hobby. The evidence is CWF Freeware. There's some really handy php functions out there for string manipulation. And since I once needed this, and because I've heard many other's have needed this too, I'll share it with you my readers. (Yes, with both of you :D)
Just a compulsory disclaimer before representing it:
This is one of the functions which I did when I was still a beginner with STL. So there's propably hundred's of more efficient and elegant solutions, and those may be posted in comments here. I'll be glad to see them. But since I happened to find this function from my archives now, I'll give it now. It may be buggy, it may be flawed, but it sure is better than having no explode() in C++ at all. (And yes, standard libraries do not offer explode function in C or C++).
/* This one 'explodes' a string (cuts it into pieces based on some matchstring) and puts pieces into a vector. arguments are the string to be cutted, matchstring and the vector where to store pieces. It returns amount of pieces, and if no matchstring is found it returns -1. */
int explode(string tear_me,string cut,vector
unsigned int start=0;