range based arr

PHOTO EMBED

Tue Oct 03 2023 19:10:19 GMT+0000 (Coordinated Universal Time)

Saved by @ivo8871 #cpp

    // 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 << ' ';
content_copyCOPY