for Loop in C++ — a practical guide to C++ for loop with clear examples you can reuse in real projects.
C++ Tutorial Series (29/111). Prefer one article? Read the complete C++ tutorial.
Short description
Range-for is idiomatic for STL containers.
for + range-for
for (int i = 0; i < n; ++i) { /* ... */ }
for (const auto& item : items) { /* ... */ }