std::vector<std::string>::iterator vec;
while( vec != exploded.end() )
std::vector<std::string> string_explode( const std::string& src, char delimiter )
{
std::vector<std::string> exploded;
std::string::size_type curPos = 0;
std::string::size_type delimPos;
std::cout << "WHOLE STRING: " << src;
while( ( delimPos = src.find( delimiter, curPos ) ) != std::string::npos )
{
std::string substr = src.substr(curPos, delimPos - curPos);
std::cout << "SUBSTR: " << substr << std::endl;
exploded.push_back( substr );
curPos = delimPos+1;
}
std::cout << "WORK DONE" << std::endl;
return exploded;
}
std::vector<std::string> string_explode( const std::string& src, char delimiter )
{
std::vector<std::string> exploded;
std::string::size_type curPos = 0;
std::string::size_type delimPos;
std::cout << "WHOLE STRING: " << src;
while( ( delimPos = src.find( delimiter, curPos ) ) != std::string::npos )
{
std::string substr = src.substr(curPos, delimPos - curPos);
std::cout << "SUBSTR: " << substr << std::endl;
exploded.push_back( substr );
curPos = delimPos+1;
}
//Grab remainder
if(curPos < src.size() )
exploded.push_back(src.substr(curPos, src.size() - curPos) );
std::cout << "WORK DONE" << std::endl;
return exploded;
}
Produces the following endless output:
I like being split.
Into multiple pieces.
Because I'm just weird that way.
SUBSTR: WORK DONE
Obviously I'm doing something wrong. But I can't figure out what.