1234567891011121314
// range-based for loop #include <iostream> #include <string> using namespace std; int main () { string str {"Hello!"}; for (char c : str) { std::cout << "[" << c << "]"; } std::cout << '\n'; }
1234
for(auto c : str) // or if I want to tweak the string auto &c { /* ... */ }