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 177 views
1 answer 150 views
1 answer 145 views
145 views asked Feb 23, 2018 by avibootz
2 answers 229 views
1 answer 89 views
...