// Iterating over whole array
std::vector<int> v = { 0, 1, 2, 3, 4, 5 };
for (auto i : v)
std::cout << i << ' ';
std::cout << '\n';
// Iterating over array
int a[] = { 0, 1, 2, 3, 4, 5 };
for (int n : a)
std::cout << n << ' ';
s
td::cout << '\n';
// the initializer may be a braced-init-list
for (int n : { 0, 1, 2, 3, 4, 5 })
std::cout << n << ' ';
std::cout << '\n';
// Printing string characters
std::string str = "Geeks";
for (char c : str)
std::cout << c << ' ';
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter