Modern C++ offers range-based for: for (char c : s). This iterates through each character without managing an index. Variable c takes each character's value in sequence. Cleaner when position isn't needed.
The loop reads by value. To modify characters, use reference: for (char& c : s). Now c refers to actual character in string, and changes to c modify the original. Use range-based for simple traversal: counting, checking conditions, reading once.
Use index-based when you need position, need to compare neighbors, or need to skip elements.