All pastes #264856 Raw Edit

Sans titre

public text v1 · immutable
·published 2006-12-02 20:01 UTC
rendered paste body
> function: splitting strings and returning the substrings in an array. Is
> there any equivalent to this in "old-style" MFC C++?[/color]

If by "old-style" you mean "standard", you might do something like this:

#include <vector>
#include <string>
#include <iostream>

void split_string(const std::string& source, const std::string& delims,
std::vector<std::string>& result)
{
std::string::size_type begin(0);
std::string::size_type end(0);

while (end != std::string::npos)
{
end = source.find_first_of(delims, begin);
result.push_back(source.substr(begin, end - begin));
begin = end + 1;
}
}

int main()
{
std::vector<std::string> strings;
split_string("This |is^ a string with;[ several ]delimiters.", ";[]^|",
strings);

for (std::vector<std::string>::size_type i = 0; i < strings.size(); ++i)
{
std::cout << '"' << strings[i] << '"' << std::endl;
}
}