How to initialize an array object in C++

1 Answer

0 votes
#include <iostream>
#include <array>
  
int main () {
    std::array<int, 5> arr = {1, 4, 8, 3, 8};

    for (int &n : arr) std::cout << n << ", ";
  
    return 0;
}
  
  
  
/*
run:
  
1, 4, 8, 3, 8, 
   
*/

 



answered Jul 29, 2020 by avibootz

Related questions

1 answer 171 views
1 answer 148 views
1 answer 143 views
143 views asked Feb 23, 2018 by avibootz
2 answers 226 views
1 answer 84 views
...