[Solved] Split string into N parts [closed]
You can do it recursively. First part size m = (str_size+N-1)/N; Then str_size -= m; and N–; A little example: #include <iostream> #include <vector> #include <string> std::vector<std::string> split_string(const std::string& s, int N) { std::vector<std::string> vect; if (N > s.size()) return vect; vect.resize(N); int n = s.size(); auto it = s.begin(); int Nnew = N; for … Read more