I know of the simple way to iterate, for instance, over every character of a string as so:
std::string some_string("Hello World");
for(auto character : some_string)
std::cout << character << std::endl;
But is there a way to use this construction to also tell it to take steps, or take specific lengths of the container in this way? Or would I have to use the classic int i = 0; i < some_string.length(); i+=2
construction for iterating over the string indices and storing parts of it with string.substr()
? For instance if I wanted to store every 2 characters of a string as a substring.