int arr[] = {1, 2, 3, 4, 5}; for(auto it = std::begin(arr); it != std::end(arr); ++it){ std::cout << *it << " "; } // Output: 1 2 3 4 5
std::vectorIn this example, we have used std::end with a std::vector container. The iterator type is automatically determined based on the container being used. Package/library: This function is a part of the C++ Standard Library.vect{1, 2, 3, 4, 5}; for(auto it = std::begin(vect); it != std::end(vect); ++it){ std::cout << *it << " "; } // Output: 1 2 3 4 5