fork download
  1. #include <iostream>
  2. #include <array>
  3. #include <utility>
  4.  
  5. std::pair< std::array<int,3>, std::array<char,4> > array_function()
  6. {
  7. //does alot of maths here
  8. std::array<int,3> numbers = { 1, 2, 3 } ;
  9. std::array<char,4> letters = { 't', 'y', 'u', 'w' } ;
  10.  
  11. //return both arrays
  12. return { numbers, letters } ;
  13. }
  14.  
  15. int main()
  16. {
  17. auto p = array_function() ;
  18.  
  19. auto int_array = p.first ;
  20. for( int i : int_array ) std::cout << i << ' ' ;
  21. std::cout << '\n' ;
  22.  
  23. auto char_array = p.second ;
  24. for( char c : char_array ) std::cout << c ;
  25. std::cout << '\n' ;
  26. }
  27.  
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
1 2 3 
tyuw