Split string using loop to specific length sub-units
string str("0123456789asdf");
for (unsigned i = 0; i < str.length(); i += 4) {
cout << str.substr(i, 4) << endl;
}
so I found this page which is pretty much what I want, but instead of print the values, I need to store them as a vector, this code gives "0123" "4567" "89as" "df", but I need to store them in a vector , also since the last element is "df" I need to attach 2 more "2"s to make it "df22"(i.e. if the desired length is 5 then it should be "01234" "56789" "asdf1" because 5-4=1), is there any way to do that?