How to extract array into structure binding elements in C++

1 Answer

0 votes
#include <iostream>

int main() {
    double array[3] = { 1.4, 2.6, 3.14 };  
    
    auto [x, y, z] = array;

 
    std::cout << x << ' ' << y << ' ' << z;
}
 
 
 
 
/*
run:
 
1.4 2.6 3.14
 
*/
 

 



answered Dec 8, 2023 by avibootz

Related questions

1 answer 119 views
1 answer 112 views
2 answers 142 views
1 answer 100 views
2 answers 160 views
...