I need to split input string (a space delimited array of words), into a string array with maximum length M
without breakdown any word. How can do this in C++?
For example:
std::string inputStr = "I need to split input string";
unsigned M = 10;
// split M characters by M characters
std::vector<std::string> output = split_string(inputStr, " ", M);
//output contains {"I need to ","split ","input ","string"}