Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Prodentim Probiotics Specially Designed For The Health Of Your Teeth And Gums

Instant Grammar Checker - Correct all grammar errors and enhance your writing

Teach Your Child To Read

Powerful WordPress hosting for WordPress professionals

Disclosure: My content contains affiliate links.

31,166 questions

40,722 answers

573 users

How to use iterator from the end to the beginning (backwards) of array object in C++

Booking.com | Official site | The best hotels, flights, car rentals & accommodations


81 views
asked Jul 28, 2020 by avibootz
edited Jul 28, 2020 by avibootz

1 Answer

0 votes
#include <iostream>
#include <array>
 
int main () {
    std::array<int, 5> arr;
 
    for (int i = 0; i < 5; i++) arr.at(i) = i + 1;

    for (auto it = arr.crbegin(); it != arr.crend(); it++)
        std::cout << *it << ", ";
 
  return 0;
}
 
 
 
/*
run:
 
5, 4, 3, 2, 1, 
  
*/

 





answered Jul 28, 2020 by avibootz

Related questions

2 answers 95 views
2 answers 75 views
1 answer 55 views
1 answer 65 views
...